Skip to content

Commit

Permalink
organize most stuff and add easy handling for different shader model …
Browse files Browse the repository at this point in the history
…versions
  • Loading branch information
Srlion committed Feb 4, 2025
1 parent cb652b3 commit 1f7767b
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
shell: pwsh
run: |
.\build_shaders.bat
tar -czf RNDX.tar.gz shaders
tar -czf RNDX.tar.gz src/shaders
copy RNDX.tar.gz C:\RNDX.tar.gz
copy rndx.lua C:\rndx.lua
copy src/rndx.lua C:\rndx.lua
- name: Release
if: runner.os == 'Windows'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.inc
sound.cache
shaders
src/shaders
File renamed without changes.
52 changes: 0 additions & 52 deletions bin/process_shaders.ps1

This file was deleted.

57 changes: 53 additions & 4 deletions build_shaders.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,57 @@
@echo off
setlocal enabledelayedexpansion

echo Building inc files and worklist for %inputbase%...
set "File=compile_shader_list.txt"

powershell -NoLogo -ExecutionPolicy Bypass -Command "bin\process_shaders.ps1 'compile_shader_list.txt'"
set "validVersions=20b 30"
set "fallbackVersion=20b"

echo Done!
echo.
REM Open the file for reading
for /f "usebackq tokens=* delims=" %%A in ("%File%") do (
set "line=%%A"

REM Skip empty lines or lines starting with comments
echo !line! | findstr /r /c:"^\s*$" >nul
if !errorlevel! equ 0 (
REM Skip the line
continue
)
echo !line! | findstr /r /c:"^\s*//" >nul
if !errorlevel! equ 0 (
REM Skip the line
continue
)

REM Trim whitespace from the line
set "line=!line: =!"

REM Extract all valid versions present in the line using the -v-(version) format
set "versionsInLine="
for %%V in (%validVersions%) do (
echo !line! | findstr /r /c:"-v-%%V" >nul && set "versionsInLine=!versionsInLine! %%V"
)

REM If no valid versions are found, fallback to the default version
if "!versionsInLine!"=="" (
echo Warning: No valid version found in line: !line!. Falling back to version %fallbackVersion%.
set "versionsInLine=%fallbackVersion%"
)

REM Strip all -v-(version) flags from the line
set "cleanedLine=!line!"
for %%V in (%validVersions%) do (
set "cleanedLine=!cleanedLine:-v-%%V=! "
)
set "cleanedLine=!cleanedLine: =!"

REM Compile for each valid version found in the line (or the fallback version)
for %%V in (!versionsInLine!) do (
set "compileArgs=/O 3 -ver %%V -shaderpath %CD%/src !cleanedLine!"

echo Compiling '!cleanedLine!' with version '%%V'
call "ShaderCompile.exe" !compileArgs!
)
)

endlocal
exit /b 0
8 changes: 4 additions & 4 deletions compile_shader_list.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rndx_r_shaders1_ps2x.hlsl
rndx_bv_shaders1_ps30.hlsl
rndx_bh_shaders1_ps30.hlsl
rndx_vertex_shaders1_vs30.hlsl
rndx_r_shaders1_psxx.hlsl -v-20b -v-30
rndx_bh_shaders1_psxx.hlsl -v-30
rndx_bv_shaders1_psxx.hlsl -v-30
rndx_vertex_shaders1_vsxx.hlsl -v-30
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1f7767b

Please sign in to comment.