Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,5 @@ nunit-*.xml
/Brovan/.vs
/.vs
/Brovan/.cache
/Brovan.Graphics/brovvulk-icd/generated
/VirtualFS
3 changes: 2 additions & 1 deletion Brovan.Generators/Brovan.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<ImplicitUsings>disable</ImplicitUsings>
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
<IsPackable>false</IsPackable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<EnforceExtendedAnalyzerRules>false</EnforceExtendedAnalyzerRules>
<NoWarn>$(NoWarn);RS1035</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1,206 changes: 1,206 additions & 0 deletions Brovan.Generators/VulkanForwardGenerator.cs

Large diffs are not rendered by default.

33,264 changes: 33,264 additions & 0 deletions Brovan.Generators/vk.xml

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions Brovan.Graphics/brovvulk-icd/BrovVulkIcd.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Nullable>disable</Nullable>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>

<ItemGroup>
<Compile Include="BrovVulkIcd.marker.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Brovan\Brovan.csproj" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
<None Include="vulkan_shim.c" />
<None Include="build.bat" />
<None Include="build.sh" />
</ItemGroup>

<Target Name="BuildBrovVulkShimWindows" AfterTargets="Build" Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<Exec Command="&quot;$(MSBuildProjectDirectory)\build.bat&quot;" />
</Target>

<Target Name="BuildBrovVulkShimUnix" AfterTargets="Build" Condition="!$([MSBuild]::IsOSPlatform('Windows'))">
<Exec Command="sh &quot;$(MSBuildProjectDirectory)/build.sh&quot;" />
</Target>

</Project>
3 changes: 3 additions & 0 deletions Brovan.Graphics/brovvulk-icd/BrovVulkIcd.marker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace BrovVulkIcd
{
}
95 changes: 95 additions & 0 deletions Brovan.Graphics/brovvulk-icd/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
@echo off
setlocal EnableExtensions EnableDelayedExpansion

set "HERE=%~dp0"
set "REPO=%GITHUB_WORKSPACE%"

if not defined REPO (
for /f "delims=" %%i in ('git -C "%HERE%" rev-parse --show-toplevel 2^>nul') do set "REPO=%%i"
)

if not defined REPO (
for %%i in ("%HERE%..\..") do set "REPO=%%~fi"
)

if not exist "%HERE%obj\generated\brovvulk_gen.c" (
echo error: generated sources missing. Build the Brovan project first ^(it runs the code generator^). 1>&2
exit /b 1
)

if not exist "%HERE%obj\generated\exports.def" (
echo error: generated exports.def missing. 1>&2
exit /b 1
)

if not exist "%HERE%bin" mkdir "%HERE%bin"
if not exist "%HERE%obj\build" mkdir "%HERE%obj\build"

where cl >nul 2>&1
if errorlevel 1 call :init_msvc
where cl >nul 2>&1
if errorlevel 1 (
echo error: cl.exe not found. Run this from a Visual Studio developer environment on GitHub Actions Windows runners. 1>&2
exit /b 1
)

pushd "%HERE%"
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
if errorlevel 1 (
popd
exit /b 1
)
popd

echo Deploying vulkan-1.dll:
call :deploy "%REPO%\VirtualFS"

if exist "%REPO%\Brovan\bin" (
for /r "%REPO%\Brovan\bin" %%E in (Brovan.exe) do call :deploy "%%~dpE\VirtualFS"
)

if exist "%REPO%\Brovan.Graphics" (
for /r "%REPO%\Brovan.Graphics" %%E in (Brovan.exe) do call :deploy "%%~dpE\VirtualFS"
)

exit /b 0

:init_msvc
set "VSDEVCMD="
for %%P in (
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Professional\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
) do (
if exist %%~P (
set "VSDEVCMD=%%~P"
goto :have_vsdevcmd
)
)

for /f "usebackq delims=" %%P in (`where vswhere.exe 2^>nul`) do (
for /f "usebackq delims=" %%Q in (`"%%P" -latest -products * -requires Microsoft.Component.MSBuild -find Common7\Tools\VsDevCmd.bat 2^>nul`) do (
if exist "%%Q" (
set "VSDEVCMD=%%Q"
goto :have_vsdevcmd
)
)
)

exit /b 1

:have_vsdevcmd
call "%VSDEVCMD%" -arch=amd64 -host_arch=amd64 >nul
exit /b 0

:deploy
set "VFS=%~1\C\Windows\System32"
if not exist "%VFS%" mkdir "%VFS%"
copy /Y "%HERE%bin\vulkan-1.dll" "%VFS%\vulkan-1.dll" >nul
echo deployed -^> %VFS%\vulkan-1.dll
exit /b 0
69 changes: 69 additions & 0 deletions Brovan.Graphics/brovvulk-icd/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/sh
set -eu

SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
REPO="$(cd "$SCRIPT_DIR/../.." && pwd)"
CC="${CC:-x86_64-w64-mingw32-gcc}"

if ! command -v "$CC" >/dev/null 2>&1; then
if command -v apt-get >/dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
if [ "$(id -u)" -eq 0 ]; then
apt-get update
apt-get install -y mingw-w64
elif command -v sudo >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y mingw-w64
else
echo "error: '$CC' not found and sudo is unavailable to install mingw-w64." >&2
exit 1
fi
fi
fi

if ! command -v "$CC" >/dev/null 2>&1; then
echo "error: MinGW-w64 compiler '$CC' not found on PATH. Install mingw-w64 or set CC." >&2
exit 1
fi

if [ ! -f "$SCRIPT_DIR/obj/generated/brovvulk_gen.c" ]; then
echo "error: generated sources missing. Build the Brovan project first (it runs the code generator)." >&2
exit 1
fi

if [ ! -f "$SCRIPT_DIR/obj/generated/exports.def" ]; then
echo "error: generated exports.def missing." >&2
exit 1
fi

mkdir -p "$SCRIPT_DIR/bin"

"$CC" -O2 -shared \
-o "$SCRIPT_DIR/bin/vulkan-1.dll" \
"$SCRIPT_DIR/vulkan_shim.c" "$SCRIPT_DIR/obj/generated/exports.def" \
-I "$SCRIPT_DIR" -I "$SCRIPT_DIR/../vulkan-headers" \
-static -static-libgcc -static-libstdc++ \
-Wl,--out-implib,"$SCRIPT_DIR/bin/libvulkan-1.a" \
-lkernel32

deploy_one() {
dst="$1/C/Windows/System32"
mkdir -p "$dst"
cp -f "$SCRIPT_DIR/bin/vulkan-1.dll" "$dst/vulkan-1.dll"
echo " deployed -> $dst/vulkan-1.dll"
}

echo "Deploying vulkan-1.dll:"
deploy_one "$REPO/VirtualFS"

if [ -d "$REPO/Brovan/bin" ]; then
find "$REPO/Brovan/bin" -type f -name Brovan.exe 2>/dev/null | while IFS= read -r exe; do
deploy_one "$(dirname "$exe")/VirtualFS"
done
fi

if [ -d "$REPO/Brovan.Graphics" ]; then
find "$REPO/Brovan.Graphics" -type f -name Brovan.exe 2>/dev/null | while IFS= read -r exe; do
deploy_one "$(dirname "$exe")/VirtualFS"
done
fi
Loading
Loading