Mercurial > games > semicongine
comparison src/zamikongine/shader.nim @ 33:94c38e4b5782
did: refactoring, move more from make to nimscript
author | Sam <sam@basx.dev> |
---|---|
date | Sun, 15 Jan 2023 23:23:54 +0700 |
parents | 9edca5dc4e93 |
children | c3c963e7c1a6 |
comparison
equal
deleted
inserted
replaced
32:9edca5dc4e93 | 33:94c38e4b5782 |
---|---|
33 | 33 |
34 proc compileGLSLToSPIRV(stage: VkShaderStageFlagBits, shaderSource: string, entrypoint: string): seq[uint32] {.compileTime.} = | 34 proc compileGLSLToSPIRV(stage: VkShaderStageFlagBits, shaderSource: string, entrypoint: string): seq[uint32] {.compileTime.} = |
35 let stagename = stage2string(stage) | 35 let stagename = stage2string(stage) |
36 | 36 |
37 # TODO: compiles only on linux for now (because we don't have compile-time functionality in std/tempfile) | 37 # TODO: compiles only on linux for now (because we don't have compile-time functionality in std/tempfile) |
38 if not defined(linux): | |
39 raise newException(Exception, "Compilation is currently only supported on linux (need mktemp command), sorry!") | |
40 let (tmpfile, exitCode) = gorgeEx(command=fmt"mktemp --tmpdir shader_XXXXXXX.{stagename}") | 38 let (tmpfile, exitCode) = gorgeEx(command=fmt"mktemp --tmpdir shader_XXXXXXX.{stagename}") |
41 if exitCode != 0: | 39 if exitCode != 0: |
42 raise newException(Exception, tmpfile) | 40 raise newException(Exception, tmpfile) |
43 | 41 |
44 let (output, exitCode_glsl) = gorgeEx(command=fmt"{querySetting(projectPath)}/glslangValidator --entry-point {entrypoint} -V --stdin -S {stagename} -o {tmpfile}", input=shaderSource) | 42 let (output, exitCode_glsl) = gorgeEx(command=fmt"{querySetting(projectPath)}/glslangValidator --entry-point {entrypoint} -V --stdin -S {stagename} -o {tmpfile}", input=shaderSource) |