# HG changeset patch # User Sam # Date 1710840707 -25200 # Node ID 8235d727183e51612bedae9acde1bd7a4b5bf051 # Parent 6962a15f375c88e931bdb6de5d72d107892b4c7f did: improve handling of shader compilation diff -r 6962a15f375c -r 8235d727183e semicongine/vulkan/shader.nim --- 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("\\", "/") diff -r 6962a15f375c -r 8235d727183e tools/glslangValidator.exe Binary file tools/glslangValidator.exe has changed