Move CultMath into the CultLib monorepo

This commit is contained in:
Meta Vens 2026-08-26 17:35:51 +02:00
commit ea88cfcd05
98 changed files with 3574 additions and 4 deletions

View file

@ -0,0 +1,69 @@
param(
[Parameter(Mandatory = $true)]
[string]$ShaderPath,
[Parameter(Mandatory = $true)]
[string]$OutputPath,
[string]$EntryPoint = "main",
[string]$Profile = "cs_6_0",
[string[]]$IncludePath = @(),
[string]$TargetEnv = "",
[int]$VulkanCBufferShift = 0,
[int]$VulkanTextureShift = 10,
[int]$VulkanUavShift = 20,
[int]$VulkanSamplerShift = 30,
[string]$DxcPath = ""
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
if (-not $DxcPath) {
$DxcPath = Join-Path $repoRoot ".tools\dxc\current\bin\x64\dxc.exe"
}
if (-not (Test-Path $DxcPath)) {
throw "DXC not found at '$DxcPath'. Run tools\get-dxc.ps1 first or pass -DxcPath."
}
$resolvedShader = Resolve-Path $ShaderPath
$resolvedIncludes = @((Join-Path $repoRoot "shaders"))
foreach ($path in $IncludePath) {
$resolvedIncludes += (Resolve-Path $path)
}
$outputDirectory = Split-Path -Parent $OutputPath
if ($outputDirectory) {
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
}
$arguments = @(
"-T", $Profile,
"-E", $EntryPoint,
"-spirv"
)
if ($TargetEnv) {
$arguments += "-fspv-target-env=$TargetEnv"
}
$arguments += @(
"-fvk-b-shift", $VulkanCBufferShift.ToString(), "0",
"-fvk-t-shift", $VulkanTextureShift.ToString(), "0",
"-fvk-u-shift", $VulkanUavShift.ToString(), "0",
"-fvk-s-shift", $VulkanSamplerShift.ToString(), "0"
)
foreach ($include in $resolvedIncludes) {
$arguments += @("-I", $include)
}
$arguments += @($resolvedShader, "-Fo", $OutputPath)
& $DxcPath @arguments
if ($LASTEXITCODE -ne 0) {
throw "dxc.exe failed with exit code $LASTEXITCODE."
}
Get-Item -LiteralPath $OutputPath

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b47e7016a99a5d148bc44c399c13c4d3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
param(
[Parameter(Mandatory = $true)]
[string]$SpirvPath,
[Parameter(Mandatory = $true)]
[string]$OutputPath,
[int]$MslVersion = 23000,
[string]$SpirvCrossPath = ""
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
if (-not $SpirvCrossPath) {
$SpirvCrossPath = Join-Path $repoRoot ".tools\spirv-cross\build\spirv-cross.exe"
}
if (-not (Test-Path $SpirvCrossPath)) {
throw "SPIRV-Cross not found at '$SpirvCrossPath'. Run tools\get-spirv-cross.ps1 first or pass -SpirvCrossPath."
}
$resolvedSpirv = Resolve-Path $SpirvPath
$outputDirectory = Split-Path -Parent $OutputPath
if ($outputDirectory) {
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
}
& $SpirvCrossPath $resolvedSpirv --msl --msl-version $MslVersion --output $OutputPath
if ($LASTEXITCODE -ne 0) {
throw "spirv-cross failed with exit code $LASTEXITCODE."
}
Get-Item -LiteralPath $OutputPath

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6150c8f461e471b4c8641fd32d1984ef
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,42 @@
param(
[string]$InstallRoot = ".tools\dxc"
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$installPath = Join-Path $repoRoot $InstallRoot
New-Item -ItemType Directory -Force -Path $installPath | Out-Null
$release = Invoke-RestMethod `
-Uri "https://api.github.com/repos/microsoft/DirectXShaderCompiler/releases/latest" `
-Headers @{ "User-Agent" = "CultMath-DXC-Bootstrap" }
$asset = $release.assets |
Where-Object { $_.name -like "dxc_*.zip" } |
Select-Object -First 1
if (-not $asset) {
throw "No Windows dxc_*.zip asset found on the latest DirectXShaderCompiler release."
}
$zipPath = Join-Path $installPath $asset.name
Remove-Item -LiteralPath $zipPath -Force -ErrorAction SilentlyContinue
& curl.exe -L --retry 5 --retry-delay 2 --fail -o $zipPath $asset.browser_download_url
if ($LASTEXITCODE -ne 0) {
throw "curl.exe failed with exit code $LASTEXITCODE."
}
$currentPath = Join-Path $installPath "current"
Remove-Item -LiteralPath $currentPath -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $currentPath | Out-Null
Expand-Archive -LiteralPath $zipPath -DestinationPath $currentPath -Force
$dxcPath = Join-Path $currentPath "bin\x64\dxc.exe"
if (-not (Test-Path $dxcPath)) {
throw "DXC x64 executable was not found after extraction."
}
& $dxcPath --version
Write-Host "DXC installed at $dxcPath"

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 86d0b9a1006042745b7fff523831049c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
param(
[string]$InstallRoot = ".tools\spirv-cross"
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$installPath = Join-Path $repoRoot $InstallRoot
$sourcePath = Join-Path $installPath "src"
$buildPath = Join-Path $installPath "build"
New-Item -ItemType Directory -Force -Path $installPath | Out-Null
if (-not (Test-Path $sourcePath)) {
git clone --depth 1 https://github.com/KhronosGroup/SPIRV-Cross.git $sourcePath
}
cmake `
-S $sourcePath `
-B $buildPath `
-G Ninja `
-DSPIRV_CROSS_CLI=ON `
-DSPIRV_CROSS_ENABLE_TESTS=OFF `
-DSPIRV_CROSS_ENABLE_C_API=OFF
cmake --build $buildPath --target spirv-cross --config Release
$spirvCrossPath = Join-Path $buildPath "spirv-cross.exe"
if (-not (Test-Path $spirvCrossPath)) {
throw "SPIRV-Cross executable was not found after build."
}
& $spirvCrossPath --version
Write-Host "SPIRV-Cross installed at $spirvCrossPath"

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: dcf41da07502f4b439f8fc5ad25d16c9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: