Mercurial > games > semicongine
changeset 917:8235d727183e
did: improve handling of shader compilation
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 19 Mar 2024 16:31:47 +0700 |
parents | 6962a15f375c |
children | 71559c2468ea |
files | semicongine/vulkan/shader.nim tools/glslangValidator.exe |
diffstat | 2 files changed, 16 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/vulkan/shader.nim Mon Mar 18 23:43:32 2024 +0700 +++ b/semicongine/vulkan/shader.nim Tue Mar 19 16:31:47 2024 +0700 @@ -52,22 +52,24 @@ let stagename = stage2string(stage) shaderHash = hash(shaderSource) - # cross compilation for windows workaround, sorry computer shaderfile = getTempDir() / &"shader_{shaderHash}.{stagename}" - projectPath = querySetting(projectPath) + - echo "shader of type ", stage, ", entrypoint ", entrypoint - for i, line in enumerate(shaderSource.splitlines()): - echo " ", i + 1, " ", line - var glslExe = "glslangValidator" - when defined(windows): - glslExe = glslExe & "." & ExeExt - let command = &"{projectPath.joinPath(glslExe)} --entry-point {entrypoint} -V --stdin -S {stagename} -o {shaderfile}" - echo "run: ", command - discard staticExecChecked( - command = command, - input = shaderSource - ) + if not shaderfile.fileExists: + echo "shader of type ", stage, ", entrypoint ", entrypoint + for i, line in enumerate(shaderSource.splitlines()): + echo " ", i + 1, " ", line + var glslExe = currentSourcePath.parentDir().parentDir() / "tools" / "glslangValidator" + when defined(windows): + glslExe = glslExe & "." & ExeExt + let command = &"{glslExe} --entry-point {entrypoint} -V --stdin -S {stagename} -o {shaderfile}" + echo "run: ", command + discard staticExecChecked( + command = command, + input = shaderSource + ) + else: + echo &"shaderfile {shaderfile} is up-to-date" when defined(mingw) and defined(linux): # required for crosscompilation, path separators get messed up let shaderbinary = staticRead shaderfile.replace("\\", "/")