changeset 483:73a0954beabd

did: improve alotof_triangles example, remove glslang lib, use only binary, easier cross-compilation
author Sam <sam@basx.dev>
date Wed, 11 Jan 2023 00:43:17 +0700
parents 1670f8e70964
children 04605ca6dd8a
files Makefile config.nims examples/alotof_triangles.nim src/zamikongine/engine.nim src/zamikongine/glslang/glslang.nim src/zamikongine/glslang/glslang_c_interface.nim src/zamikongine/glslang/glslang_c_shader_types.nim src/zamikongine/math/matrix.nim src/zamikongine/shader.nim src/zamikongine/vulkan_helpers.nim
diffstat 10 files changed, 152 insertions(+), 599 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Jan 10 00:24:37 2023 +0700
+++ b/Makefile	Wed Jan 11 00:43:17 2023 +0700
@@ -1,115 +1,86 @@
 SOURCES := $(shell find src -name '*.nim')
 
-# HACK to get cross-compilation working --------------------------------
-
-# anywhere with a windows filesystem that has the visual basic compiler tools installed
-WINDOWS_BASE := /mnt
-
-# path variables, need to have correct versions
-WINDOWS_PROGAMS := ${WINDOWS_BASE}/Program Files (x86)
-MSVC_BUILDTOOLS_PATH := ${WINDOWS_PROGAMS}/Microsoft Visual Studio/2022/BuildTools/VC
-WINDOWS_KIT_INCLUDE_BASE := ${WINDOWS_PROGAMS}/Windows Kits/10/Include/10.0.22000.0
-WINDOWS_KIT_LIBS_BASE := ${WINDOWS_PROGAMS}/Windows Kits/10/Lib/10.0.22000.0
-MSVC_PATH := ${MSVC_BUILDTOOLS_PATH}/Tools/MSVC/14.34.31933
-
-MSVC_ADDITIONAL_PATH := ${MSVC_BUILDTOOLS_PATH}/Auxiliary/Build/
-CL_DIR := ${MSVC_PATH}/bin/Hostx64/x64/
-CL_INCL_DIR := ${MSVC_PATH}/include
-WINE_NIM_VERSION := 1.6.10
-
-# nim command:
-WINE_NIM := WINEPATH="${CL_DIR}" wine ./build/nim_windows/nim-${WINE_NIM_VERSION}/bin/nim.exe --path:"${MSVC_ADDITIONAL_PATH}" --path:"${CL_INCL_DIR}" --passC:'/I "${CL_INCL_DIR}"' --passC:'/I "${WINDOWS_KIT_INCLUDE_BASE}/ucrt"' --passC:'/I "${WINDOWS_KIT_INCLUDE_BASE}/um"' --passC:'/I "${WINDOWS_KIT_INCLUDE_BASE}/shared"' --passL:'/LIBPATH:"${WINDOWS_KIT_LIBS_BASE}/ucrt/x64"' --passL:'/LIBPATH:"${WINDOWS_KIT_LIBS_BASE}/um/x64"' --passL:'/LIBPATH:"${MSVC_PATH}/lib/x64"'
-
-# end of HACK-----------------------------------------------------------
-
-
 # build hello_triangle
 build/debug/linux/hello_triangle: ${SOURCES}
 	nim build_linux_debug -o:$@ examples/hello_triangle.nim
 build/release/linux/hello_triangle: ${SOURCES}
 	nim build_linux_release -o:$@ examples/hello_triangle.nim
 build/debug/windows/hello_triangle.exe: ${SOURCES} build/nim_windows
-	${WINE_NIM} build_windows_debug -o:$@ examples/hello_triangle.nim
+	# ${WINE_NIM} build_windows_debug -o:$@ examples/hello_triangle.nim
+	nim build_windows_debug -o:$@ examples/hello_triangle.nim
 build/release/windows/hello_triangle.exe: ${SOURCES} build/nim_windows
-	${WINE_NIM} build_windows_release -o:$@ examples/hello_triangle.nim
+	nim build_windows_release -o:$@ examples/hello_triangle.nim
 
+# build alotof_triangles
 build/debug/linux/alotof_triangles: ${SOURCES}
 	nim build_linux_debug -o:$@ examples/alotof_triangles.nim
 build/release/linux/alotof_triangles: ${SOURCES}
 	nim build_linux_release -o:$@ examples/alotof_triangles.nim
 build/debug/windows/alotof_triangles.exe: ${SOURCES} build/nim_windows
-	${WINE_NIM} build_windows_debug -o:$@ examples/alotof_triangles.nim
+	nim build_windows_debug -o:$@ examples/alotof_triangles.nim
 build/release/windows/alotof_triangles.exe: ${SOURCES} build/nim_windows
-	${WINE_NIM} build_windows_release -o:$@ examples/alotof_triangles.nim
+	nim build_windows_release -o:$@ examples/alotof_triangles.nim
 
-build_all_linux: build/debug/linux/hello_triangle build/release/linux/hello_triangle
-build_all_windows: build/debug/windows/hello_triangle.exe build/release/windows/hello_triangle.exe
-build_all: build_all_linux build_all_windows
+build_all_linux_hello_triangle: build/debug/linux/hello_triangle build/release/linux/hello_triangle
+build_all_windows_hello_triangle: build/debug/windows/hello_triangle.exe build/release/windows/hello_triangle.exe
+build_all_hello_triangle: build_all_linux_hello_triangle build_all_windows_hello_triangle
+
+build_all_linux_alotof_triangles: build/debug/linux/alotof_triangles build/release/linux/alotof_triangles
+build_all_windows_alotof_triangles: build/debug/windows/alotof_triangles.exe build/release/windows/alotof_triangles.exe
+build_all_alotof_triangles: build_all_linux_alotof_triangles build_all_windows_alotof_triangles
 
 # clean
 clean:
 	rm -rf build
-	# clean thirdparty too?
+	rm -rf thirdparty
 
 .PHONY: tests
+.PHONY: glslang-master-linux-Debug.zip
+.PHONY: glslang-master-linux-Release.zip
+.PHONY: glslang-master-windows-x64-Debug.zip
+.PHONY: glslang-master-windows-x64-Release.zip
 
 # tests
 tests:
 	testament p tests/
 
 # publish
-publish_linux_debug: build/debug/linux/hello_triangle
+publish_linux_debug_hello_triangle: build/debug/linux/hello_triangle
 	scp $< basx.dev:/var/www/public.basx.dev/joni/linux/debug/
-publish_linux_release: build/release/linux/hello_triangle
+publish_linux_release_hello_triangle: build/release/linux/hello_triangle
 	scp $< basx.dev:/var/www/public.basx.dev/joni/linux/release/
-publish_windows_debug: build/debug/linux/hello_triangle
+publish_windows_debug_hello_triangle: build/debug/linux/hello_triangle.exe
 	scp $< basx.dev:/var/www/public.basx.dev/joni/windows/debug/
-publish_windows_release: build/release/linux/hello_triangle
+publish_windows_release_hello_triangle: build/release/linux/hello_triangle.exe
 	scp $< basx.dev:/var/www/public.basx.dev/joni/windows/release/
+publish_all_linux_hello_triangle: publish_linux_debug_hello_triangle publish_linux_release_hello_triangle
+publish_all_windows_hello_triangle: publish_windows_debug_hello_triangle publish_windows_release_hello_triangle
+publish_all_alotof_hello_triangle: publish_all_linux_hello_triangle publish_all_windows_hello_triangle
 
-publish_all_linux: publish_linux_debug publish_linux_release
-publish_all_windows: publish_windows_debug publish_windows_release
-publish_all: publish_all_linux publish_all_windows
+publish_linux_debug_alotof_triangles: build/debug/linux/alotof_triangles
+	scp $< basx.dev:/var/www/public.basx.dev/joni/linux/debug/
+publish_linux_release_alotof_triangles: build/release/linux/alotof_triangles
+	scp $< basx.dev:/var/www/public.basx.dev/joni/linux/release/
+publish_windows_debug_alotof_triangles: build/debug/linux/alotof_triangles.exe
+	scp $< basx.dev:/var/www/public.basx.dev/joni/windows/debug/
+publish_windows_release_alotof_triangles: build/release/linux/alotof_triangles.exe
+	scp $< basx.dev:/var/www/public.basx.dev/joni/windows/release/
+publish_all_linux_alotof_triangles: publish_linux_debug_alotof_triangles publish_linux_release_alotof_triangles
+publish_all_windows_alotof_triangles: publish_windows_debug_alotof_triangles publish_windows_release_alotof_triangles
+publish_all_alotof_triangles: publish_all_linux_alotof_triangles publish_all_windows_alotof_triangles
 
 
 # download thirdparty-libraries
 
-thirdparty/lib/glslang/linux_debug:
-	mkdir -p $@
-	wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Debug.zip
-	unzip glslang-master-linux-Debug.zip -d $@
-thirdparty/lib/glslang/linux_release:
-	mkdir -p $@
-	wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
-	unzip glslang-master-linux-Release.zip -d $@
-thirdparty/lib/glslang/windows_debug:
-	mkdir -p $@
-	wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Debug.zip
-	unzip glslang-master-windows-x64-Debug.zip -d $@
-thirdparty/lib/glslang/windows_release:
-	mkdir -p $@
-	wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip
-	unzip glslang-master-windows-x64-Release.zip -d $@
-
-thirdparty/lib/spirv-tools/linux_debug:
+thirdparty/bin/linux: glslang-master-linux-Release.zip
 	mkdir -p $@
-	wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-gcc-debug/continuous/1899/20221216-081758/install.tgz
-	tar --directory $@ -xf $@/install.tgz
-thirdparty/lib/spirv-tools/linux_release:
-	mkdir -p $@
-	wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/linux-gcc-release/continuous/1889/20221216-081754/install.tgz
-	tar --directory $@ -xf $@/install.tgz
-thirdparty/lib/spirv-tools/windows_debug:
+	cd $@ && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/$<
+	cd $@ && unzip $<
+	cd $@ && mv bin/* .
+	cd $@ && rm -rf $< bin lib include
+thirdparty/bin/windows: glslang-master-windows-x64-Release.zip
 	mkdir -p $@
-	wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-debug/continuous/1599/20221216-081803/install.zip
-	unzip $@/install.zip -d $@
-thirdparty/lib/spirv-tools/windows_release:
-	mkdir -p $@
-	wget --directory-prefix=$@ https://storage.googleapis.com/spirv-tools/artifacts/prod/graphics_shader_compiler/spirv-tools/windows-msvc-2017-release/continuous/1885/20221216-081805/install.zip
-	unzip $@/install.zip -d $@
-
-# set up cross compilation to compile for windows on linux
-build/nim_windows/:
-	mkdir -p build/nim_windows
-	wget --directory-prefix=$@ https://nim-lang.org/download/nim-${WINE_NIM_VERSION}_x64.zip
-	unzip $@/nim-${WINE_NIM_VERSION}_x64.zip -d $@
+	cd $@ && wget https://github.com/KhronosGroup/glslang/releases/download/master-tot/$<
+	cd $@ && unzip $<
+	cd $@ && mv bin/* .
+	cd $@ && rm -rf $< bin lib include
--- a/config.nims	Tue Jan 10 00:24:37 2023 +0700
+++ b/config.nims	Wed Jan 11 00:43:17 2023 +0700
@@ -44,14 +44,16 @@
 task build_windows_debug, "build windows debug":
   compilerFlags()
   compilerFlagsDebug()
-  compilerFlagsDebugWindows()
+  # compilerFlagsDebugWindows()
+  switch("define", "mingw")
   buildbase.joinPath("debug/windows").mkDir()
   setCommand "c"
 
 task build_windows_release, "build windows release":
   compilerFlags()
   compilerFlagsRelease()
-  compilerFlagsReleaseWindows()
+  # compilerFlagsReleaseWindows()
+  switch("define", "mingw")
   buildbase.joinPath("release/windows").mkDir()
   setCommand "c"
 
--- a/examples/alotof_triangles.nim	Tue Jan 10 00:24:37 2023 +0700
+++ b/examples/alotof_triangles.nim	Wed Jan 11 00:43:17 2023 +0700
@@ -1,3 +1,4 @@
+import std/math
 import std/random
 
 import zamikongine/engine
@@ -13,13 +14,19 @@
     position11: VertexAttribute[Vec2[float32]]
     color22: VertexAttribute[Vec3[float32]]
 
+proc randomtransform(): Mat33[float32] =
+  let randomscale = scale2d(float32(rand(1.0) + 0.5), float32(rand(1.0) + 0.5))
+  let randomrotate = rotate2d(float32(rand(2 * PI)))
+  let randomtranslate = translate2d(float32(rand(1.6) - 0.8), float32(rand(1.6) - 0.8))
+  result = randomtranslate * randomrotate * randomscale
+
 when isMainModule:
   randomize()
   var myengine = igniteEngine()
   const baseTriangle = [
-    Vec3([-0.3'f32, -0.3'f32, 1'f32]),
-    Vec3([ 0.3'f32,  0.3'f32, 1'f32]),
-    Vec3([-0.3'f32,  0.3'f32, 1'f32]),
+    Vec3([-0.1'f32, -0.1'f32, 1'f32]),
+    Vec3([ 0.1'f32,  0.1'f32, 1'f32]),
+    Vec3([-0.1'f32,  0.1'f32, 1'f32]),
   ]
 
   var scene = new Thing
@@ -27,13 +34,13 @@
   for i in 1 .. 300:
     var randommesh = new Mesh[VertexDataA]
     # TODO: create randomized position11 from baseTriangle with random transformation matrix
-    var transform = (Mat33[float32]().randomized() * 2'f32) - 1'f32
+    let transform1 = randomtransform()
     randommesh.vertexData = VertexDataA(
       position11: VertexAttribute[Vec2[float32]](
         data: @[
-          Vec2[float32](transform * baseTriangle[0]),
-          Vec2[float32](transform * baseTriangle[1]),
-          Vec2[float32](transform * baseTriangle[2]),
+          Vec2[float32](transform1 * baseTriangle[0]),
+          Vec2[float32](transform1 * baseTriangle[1]),
+          Vec2[float32](transform1 * baseTriangle[2]),
         ]
       ),
       color22: VertexAttribute[Vec3[float32]](
@@ -45,13 +52,14 @@
       )
     )
 
+    let transform2 = randomtransform()
     var randomindexedmesh = new IndexedMesh[VertexDataA, uint16]
     randomindexedmesh.vertexData = VertexDataA(
       position11: VertexAttribute[Vec2[float32]](
         data: @[
-          Vec2[float32](transform * baseTriangle[0]),
-          Vec2[float32](transform * baseTriangle[1]),
-          Vec2[float32](transform * baseTriangle[2]),
+          Vec2[float32](transform2 * baseTriangle[0]),
+          Vec2[float32](transform2 * baseTriangle[1]),
+          Vec2[float32](transform2 * baseTriangle[2]),
         ]
       ),
       color22: VertexAttribute[Vec3[float32]](
@@ -62,7 +70,7 @@
         ]
       )
     )
-    randomindexedmesh.indices = @[[0'u16, 1'u16, 2'u16], [0'u16, 2'u16, 1'u16]]
+    randomindexedmesh.indices = @[[0'u16, 1'u16, 2'u16]]
     var childthing = new Thing
     childthing.parts.add randommesh
     childthing.parts.add randomindexedmesh
--- a/src/zamikongine/engine.nim	Tue Jan 10 00:24:37 2023 +0700
+++ b/src/zamikongine/engine.nim	Wed Jan 11 00:43:17 2023 +0700
@@ -15,8 +15,6 @@
 import ./thing
 import ./mesh
 
-import ./glslang/glslang
-
 const MAX_FRAMES_IN_FLIGHT = 2
 const DEBUG_LOG = not defined(release)
 
@@ -455,8 +453,6 @@
   vkLoad1_1()
   vkLoad1_2()
 
-  checkGlslangResult glslang_initialize_process()
-
   # create vulkan instance
   result.vulkan.instance = createVulkanInstance(VULKAN_VERSION)
   when DEBUG_LOG:
@@ -505,14 +501,16 @@
   var allmeshes: seq[Mesh[T]]
   for mesh in partsOfType[ref Mesh[T]](engine.currentscenedata):
     allmeshes.add(mesh[])
-  var ubermesh = createUberMesh(allmeshes)
-  engine.vulkan.vertexBuffers.add createVertexBuffers(ubermesh, engine.vulkan.device.device, engine.vulkan.device.physicalDevice.device, engine.vulkan.commandPool, engine.vulkan.device.graphicsQueue)
+  if allmeshes.len > 0:
+    var ubermesh = createUberMesh(allmeshes)
+    engine.vulkan.vertexBuffers.add createVertexBuffers(ubermesh, engine.vulkan.device.device, engine.vulkan.device.physicalDevice.device, engine.vulkan.commandPool, engine.vulkan.device.graphicsQueue)
 
   var allindexedmeshes: seq[IndexedMesh[T, U]]
   for mesh in partsOfType[ref IndexedMesh[T, U]](engine.currentscenedata):
     allindexedmeshes.add(mesh[])
-  var indexedubermesh = createUberMesh(allindexedmeshes)
-  engine.vulkan.indexedVertexBuffers.add createIndexedVertexBuffers(indexedubermesh, engine.vulkan.device.device, engine.vulkan.device.physicalDevice.device, engine.vulkan.commandPool, engine.vulkan.device.graphicsQueue)
+  if allindexedmeshes.len > 0:
+    var indexedubermesh = createUberMesh(allindexedmeshes)
+    engine.vulkan.indexedVertexBuffers.add createIndexedVertexBuffers(indexedubermesh, engine.vulkan.device.device, engine.vulkan.device.physicalDevice.device, engine.vulkan.commandPool, engine.vulkan.device.graphicsQueue)
 
 proc recordCommandBuffer(renderPass: VkRenderPass, pipeline: VkPipeline, commandBuffer: VkCommandBuffer, framebuffer: VkFramebuffer, frameDimension: VkExtent2D, engine: var Engine) =
   var
@@ -678,6 +676,5 @@
   engine.vulkan.device.device.vkDestroyDevice(nil)
   when DEBUG_LOG:
     engine.vulkan.instance.vkDestroyDebugUtilsMessengerEXT(engine.vulkan.debugMessenger, nil)
-  glslang_finalize_process()
   engine.window.trash()
   engine.vulkan.instance.vkDestroyInstance(nil)
--- a/src/zamikongine/glslang/glslang.nim	Tue Jan 10 00:24:37 2023 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-import glslang_c_interface
-import glslang_c_shader_types
-
-export
-  glslang_stage_t,
-  glslang_initialize_process,
-  glslang_finalize_process
-
-type
-  ShaderVersion = enum
-    ES_VERSION = 100
-    DESKTOP_VERSION = 110
-
-proc compileGLSLToSPIRV*(stage: glslang_stage_t, shaderSource: string, fileName: string): seq[uint32] =
-  var input = glslang_input_t(
-    stage: stage,
-    language: GLSLANG_SOURCE_GLSL,
-    client: GLSLANG_CLIENT_VULKAN,
-    client_version: GLSLANG_TARGET_VULKAN_1_2,
-    target_language: GLSLANG_TARGET_SPV,
-    target_language_version: GLSLANG_TARGET_SPV_1_5,
-    code: cstring(shaderSource),
-    default_version: ord(DESKTOP_VERSION),
-    default_profile: GLSLANG_CORE_PROFILE,
-    force_default_version_and_profile: false.cint,
-    forward_compatible: false.cint,
-    messages: GLSLANG_MSG_DEBUG_INFO_BIT,
-    resource: glslang_default_resource(),
-  )
-
-  var shader = glslang_shader_create(addr(input))
-
-  if not bool(glslang_shader_preprocess(shader, addr(input))):
-      echo "GLSL preprocessing failed " & fileName
-      echo glslang_shader_get_info_log(shader)
-      echo glslang_shader_get_info_debug_log(shader)
-      echo input.code
-      glslang_shader_delete(shader)
-      return
-
-  if not bool(glslang_shader_parse(shader, addr(input))):
-      echo "GLSL parsing failed " & fileName
-      echo glslang_shader_get_info_log(shader)
-      echo glslang_shader_get_info_debug_log(shader)
-      echo glslang_shader_get_preprocessed_code(shader)
-      glslang_shader_delete(shader)
-      return
-
-  var program: ptr glslang_program_t = glslang_program_create()
-  glslang_program_add_shader(program, shader)
-
-  if not bool(glslang_program_link(program, ord(GLSLANG_MSG_SPV_RULES_BIT) or ord(GLSLANG_MSG_VULKAN_RULES_BIT))):
-      echo "GLSL linking failed " & fileName
-      echo glslang_program_get_info_log(program)
-      echo glslang_program_get_info_debug_log(program)
-      glslang_program_delete(program)
-      glslang_shader_delete(shader)
-      return
-
-  glslang_program_SPIRV_generate(program, stage)
-
-  result = newSeq[uint32](glslang_program_SPIRV_get_size(program))
-  glslang_program_SPIRV_get(program, addr(result[0]))
-
-  var spirv_messages: cstring = glslang_program_SPIRV_get_messages(program)
-  if spirv_messages != nil:
-      echo "(%s) %s\b", fileName, spirv_messages
-
-  glslang_program_delete(program)
-  glslang_shader_delete(shader)
-
-template checkGlslangResult*(call: untyped) =
-  let value = call
-  if value != 1:
-    raise newException(Exception, "glgslang error: " & astToStr(call) & " returned " & $value)
--- a/src/zamikongine/glslang/glslang_c_interface.nim	Tue Jan 10 00:24:37 2023 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-import std/strformat
-
-when defined(linux):
-  const platform = "linux"
-when defined(windows):
-  const platform = "windows"
-
-
-when defined(release):
-  const libversion = "release"
-else:
-  const libversion = "debug"
-
-
-# required to link the GLSL compiler
-when defined(linux):
-  {.passl: &"-Lthirdparty/lib/glslang/{platform}_{libversion}" .}
-  {.passl: &"-Lthirdparty/lib/spirv-tools/{platform}_{libversion}" .}
-  {.passl: "-lglslang" .}
-  {.passl: "-lglslang-default-resource-limits" .}
-  {.passl: "-lHLSL" .}
-  {.passl: "-lMachineIndependent" .}
-  {.passl: "-lGenericCodeGen" .}
-  {.passl: "-lOSDependent" .}
-  {.passl: "-lOGLCompiler" .}
-  {.passl: "-lSPIRV" .}
-  {.passl: "-lSPIRV-Tools-opt" .}
-  {.passl: "-lSPIRV-Tools" .}
-  {.passl: "-lSPIRV-Tools-diff" .}
-  {.passl: "-lSPIRV-Tools-fuzz" .}
-  {.passl: "-lSPIRV-Tools-link" .}
-  {.passl: "-lSPIRV-Tools-lint" .}
-  {.passl: "-lSPIRV-Tools-opt" .}
-  {.passl: "-lSPIRV-Tools-reduce" .}
-
-  {.passl: "-lstdc++" .}
-  {.passl: "-lm" .}
-when defined(windows):
-  when libversion == "release":
-    const LIB_POSTFIX = ".lib"
-  when libversion == "debug":
-    const LIB_POSTFIX = "d.lib"
-  
-  {.passl: "/link" .}
-  {.passl: &"/LIBPATH:./thirdparty/lib/glslang/{platform}_{libversion}" .}
-  {.passl: &"/LIBPATH:./thirdparty/lib/spirv-tools/{platform}_{libversion}" .}
-  {.passl: "glslang" & LIB_POSTFIX .}
-  {.passl: "glslang-default-resource-limits" & LIB_POSTFIX .}
-  {.passl: "HLSL" & LIB_POSTFIX .}
-  {.passl: "MachineIndependent" & LIB_POSTFIX .}
-  {.passl: "GenericCodeGen" & LIB_POSTFIX .}
-  {.passl: "OSDependent" & LIB_POSTFIX .}
-  {.passl: "OGLCompiler" & LIB_POSTFIX .}
-  {.passl: "SPIRV" & LIB_POSTFIX .}
-  {.passl: "SPIRV-Tools-opt.lib" .}
-  {.passl: "SPIRV-Tools.lib" .}
-  {.passl: "SPIRV-Tools-diff.lib" .}
-  {.passl: "SPIRV-Tools-fuzz.lib" .}
-  {.passl: "SPIRV-Tools-link.lib" .}
-  {.passl: "SPIRV-Tools-lint.lib" .}
-  {.passl: "SPIRV-Tools-opt.lib" .}
-  {.passl: "SPIRV-Tools-reduce.lib" .}
-
-
-
-import
-  glslang_c_shader_types
-
-type 
-  glslang_shader_t* {.nodecl incompleteStruct.} = object
-  glslang_program_t* {.nodecl incompleteStruct.} = object
-  glslang_limits_t* {.bycopy.} = object
-    non_inductive_for_loops*: bool
-    while_loops*: bool
-    do_while_loops*: bool
-    general_uniform_indexing*: bool
-    general_attribute_matrix_vector_indexing*: bool
-    general_varying_indexing*: bool
-    general_sampler_indexing*: bool
-    general_variable_indexing*: bool
-    general_constant_matrix_vector_indexing*: bool
-  glslang_resource_t* {.bycopy.} = object
-    max_lights*: cint
-    max_clip_planes*: cint
-    max_texture_units*: cint
-    max_texture_coords*: cint
-    max_vertex_attribs*: cint
-    max_vertex_uniform_components*: cint
-    max_varying_floats*: cint
-    max_vertex_texture_image_units*: cint
-    max_combined_texture_image_units*: cint
-    max_texture_image_units*: cint
-    max_fragment_uniform_components*: cint
-    max_draw_buffers*: cint
-    max_vertex_uniform_vectors*: cint
-    max_varying_vectors*: cint
-    max_fragment_uniform_vectors*: cint
-    max_vertex_output_vectors*: cint
-    max_fragment_input_vectors*: cint
-    min_program_texel_offset*: cint
-    max_program_texel_offset*: cint
-    max_clip_distances*: cint
-    max_compute_work_group_count_x*: cint
-    max_compute_work_group_count_y*: cint
-    max_compute_work_group_count_z*: cint
-    max_compute_work_group_size_x*: cint
-    max_compute_work_group_size_y*: cint
-    max_compute_work_group_size_z*: cint
-    max_compute_uniform_components*: cint
-    max_compute_texture_image_units*: cint
-    max_compute_image_uniforms*: cint
-    max_compute_atomic_counters*: cint
-    max_compute_atomic_counter_buffers*: cint
-    max_varying_components*: cint
-    max_vertex_output_components*: cint
-    max_geometry_input_components*: cint
-    max_geometry_output_components*: cint
-    max_fragment_input_components*: cint
-    max_image_units*: cint
-    max_combined_image_units_and_fragment_outputs*: cint
-    max_combined_shader_output_resources*: cint
-    max_image_samples*: cint
-    max_vertex_image_uniforms*: cint
-    max_tess_control_image_uniforms*: cint
-    max_tess_evaluation_image_uniforms*: cint
-    max_geometry_image_uniforms*: cint
-    max_fragment_image_uniforms*: cint
-    max_combined_image_uniforms*: cint
-    max_geometry_texture_image_units*: cint
-    max_geometry_output_vertices*: cint
-    max_geometry_total_output_components*: cint
-    max_geometry_uniform_components*: cint
-    max_geometry_varying_components*: cint
-    max_tess_control_input_components*: cint
-    max_tess_control_output_components*: cint
-    max_tess_control_texture_image_units*: cint
-    max_tess_control_uniform_components*: cint
-    max_tess_control_total_output_components*: cint
-    max_tess_evaluation_input_components*: cint
-    max_tess_evaluation_output_components*: cint
-    max_tess_evaluation_texture_image_units*: cint
-    max_tess_evaluation_uniform_components*: cint
-    max_tess_patch_components*: cint
-    max_patch_vertices*: cint
-    max_tess_gen_level*: cint
-    max_viewports*: cint
-    max_vertex_atomic_counters*: cint
-    max_tess_control_atomic_counters*: cint
-    max_tess_evaluation_atomic_counters*: cint
-    max_geometry_atomic_counters*: cint
-    max_fragment_atomic_counters*: cint
-    max_combined_atomic_counters*: cint
-    max_atomic_counter_bindings*: cint
-    max_vertex_atomic_counter_buffers*: cint
-    max_tess_control_atomic_counter_buffers*: cint
-    max_tess_evaluation_atomic_counter_buffers*: cint
-    max_geometry_atomic_counter_buffers*: cint
-    max_fragment_atomic_counter_buffers*: cint
-    max_combined_atomic_counter_buffers*: cint
-    max_atomic_counter_buffer_size*: cint
-    max_transform_feedback_buffers*: cint
-    max_transform_feedback_interleaved_components*: cint
-    max_cull_distances*: cint
-    max_combined_clip_and_cull_distances*: cint
-    max_samples*: cint
-    max_mesh_output_vertices_nv*: cint
-    max_mesh_output_primitives_nv*: cint
-    max_mesh_work_group_size_x_nv*: cint
-    max_mesh_work_group_size_y_nv*: cint
-    max_mesh_work_group_size_z_nv*: cint
-    max_task_work_group_size_x_nv*: cint
-    max_task_work_group_size_y_nv*: cint
-    max_task_work_group_size_z_nv*: cint
-    max_mesh_view_count_nv*: cint
-    max_mesh_output_vertices_ext*: cint
-    max_mesh_output_primitives_ext*: cint
-    max_mesh_work_group_size_x_ext*: cint
-    max_mesh_work_group_size_y_ext*: cint
-    max_mesh_work_group_size_z_ext*: cint
-    max_task_work_group_size_x_ext*: cint
-    max_task_work_group_size_y_ext*: cint
-    max_task_work_group_size_z_ext*: cint
-    max_mesh_view_count_ext*: cint
-    maxDualSourceDrawBuffersEXT*: cint
-    limits*: glslang_limits_t
-  glslang_input_t* {.bycopy.} = object
-    language*: glslang_source_t
-    stage*: glslang_stage_t
-    client*: glslang_client_t
-    client_version*: glslang_target_client_version_t
-    target_language*: glslang_target_language_t
-    target_language_version*: glslang_target_language_version_t
-    code*: cstring
-    default_version*: cint
-    default_profile*: glslang_profile_t
-    force_default_version_and_profile*: cint
-    forward_compatible*: cint
-    messages*: glslang_messages_t
-    resource*: ptr glslang_resource_t
-  glsl_include_result_t* {.bycopy.} = object
-    ##  Header file name or NULL if inclusion failed
-    header_name*: cstring
-    ##  Header contents or NULL
-    header_data*: cstring
-    header_length*: csize_t
-  glsl_include_local_func* = proc (ctx: pointer; header_name: cstring; includer_name: cstring; include_depth: csize_t): ptr glsl_include_result_t
-  glsl_include_system_func* = proc (ctx: pointer; header_name: cstring; includer_name: cstring; include_depth: csize_t): ptr glsl_include_result_t
-  glsl_free_include_result_func* = proc (ctx: pointer; result: ptr glsl_include_result_t): cint
-  glsl_include_callbacks_t* {.bycopy.} = object
-    include_system*: glsl_include_system_func
-    include_local*: glsl_include_local_func
-    free_include_result*: glsl_free_include_result_func
-  glslang_spv_options_t* {.bycopy.} = object
-    generate_debug_info*: bool
-    strip_debug_info*: bool
-    disable_optimizer*: bool
-    optimize_size*: bool
-    disassemble*: bool
-    validate*: bool
-    emit_nonsemantic_shader_debug_info*: bool
-    emit_nonsemantic_shader_debug_source*: bool
-
-proc glslang_initialize_process*(): cint {.importc.}
-proc glslang_finalize_process*() {.importc.}
-proc glslang_shader_create*(input: ptr glslang_input_t): ptr glslang_shader_t {.importc.}
-proc glslang_shader_delete*(shader: ptr glslang_shader_t) {.importc.}
-proc glslang_shader_set_preamble*(shader: ptr glslang_shader_t; s: cstring) {.importc.}
-proc glslang_shader_shift_binding*(shader: ptr glslang_shader_t; res: glslang_resource_type_t; base: cuint) {.importc.}
-proc glslang_shader_shift_binding_for_set*(shader: ptr glslang_shader_t; res: glslang_resource_type_t; base: cuint; set: cuint) {.importc.}
-proc glslang_shader_set_options*(shader: ptr glslang_shader_t; options: cint) {.importc.}
-
-proc glslang_shader_set_glsl_version*(shader: ptr glslang_shader_t; version: cint) {.importc.}
-proc glslang_shader_preprocess*(shader: ptr glslang_shader_t; input: ptr glslang_input_t): cint {.importc.}
-proc glslang_shader_parse*(shader: ptr glslang_shader_t; input: ptr glslang_input_t): cint {.importc.}
-proc glslang_shader_get_preprocessed_code*(shader: ptr glslang_shader_t): cstring {.importc.}
-proc glslang_shader_get_info_log*(shader: ptr glslang_shader_t): cstring {.importc.}
-proc glslang_shader_get_info_debug_log*(shader: ptr glslang_shader_t): cstring {.importc.}
-proc glslang_program_create*(): ptr glslang_program_t {.importc.}
-proc glslang_program_delete*(program: ptr glslang_program_t) {.importc.}
-proc glslang_program_add_shader*(program: ptr glslang_program_t; shader: ptr glslang_shader_t) {.importc.}
-proc glslang_program_link*(program: ptr glslang_program_t; messages: cint): cint {.importc.}
-
-proc glslang_program_add_source_text*(program: ptr glslang_program_t; stage: glslang_stage_t; text: cstring; len: csize_t) {.importc.}
-proc glslang_program_set_source_file*(program: ptr glslang_program_t; stage: glslang_stage_t; file: cstring) {.importc.}
-proc glslang_program_map_io*(program: ptr glslang_program_t): cint {.importc.}
-proc glslang_program_SPIRV_generate*(program: ptr glslang_program_t; stage: glslang_stage_t) {.importc.}
-proc glslang_program_SPIRV_generate_with_options*(program: ptr glslang_program_t; stage: glslang_stage_t; spv_options: ptr glslang_spv_options_t) {.importc.}
-proc glslang_program_SPIRV_get_size*(program: ptr glslang_program_t): csize_t {.importc.}
-proc glslang_program_SPIRV_get*(program: ptr glslang_program_t; a2: ptr cuint) {.importc.}
-proc glslang_program_SPIRV_get_ptr*(program: ptr glslang_program_t): ptr cuint {.importc.}
-proc glslang_program_SPIRV_get_messages*(program: ptr glslang_program_t): cstring {.importc.}
-proc glslang_program_get_info_log*(program: ptr glslang_program_t): cstring {.importc.}
-proc glslang_program_get_info_debug_log*(program: ptr glslang_program_t): cstring {.importc.}
-
-proc glslang_default_resource*(): ptr glslang_resource_t {.importc.}
-proc glslang_default_resource_string*(): cstring {.importc.}
-proc glslang_decode_resource_limits*(resources: ptr glslang_resource_t , config: cstring) {.importc.}
--- a/src/zamikongine/glslang/glslang_c_shader_types.nim	Tue Jan 10 00:24:37 2023 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-type
-
-  # EShLanguage counterpart
-  glslang_stage_t* {.size: sizeof(cint).} = enum
-    GLSLANG_STAGE_VERTEX
-    GLSLANG_STAGE_TESSCONTROL
-    GLSLANG_STAGE_TESSEVALUATION
-    GLSLANG_STAGE_GEOMETRY
-    GLSLANG_STAGE_FRAGMENT
-    GLSLANG_STAGE_COMPUTE
-    GLSLANG_STAGE_RAYGEN
-    GLSLANG_STAGE_INTERSECT
-    GLSLANG_STAGE_ANYHIT
-    GLSLANG_STAGE_CLOSESTHIT
-    GLSLANG_STAGE_MISS
-    GLSLANG_STAGE_CALLABLE
-    GLSLANG_STAGE_TASK
-    GLSLANG_STAGE_MESH
-    GLSLANG_STAGE_COUNT
-
-  # EShLanguageMask counterpart
-  glslang_stage_mask_t* {.size: sizeof(cint).} = enum
-    GLSLANG_STAGE_VERTEX_MASK = (1 shl ord(GLSLANG_STAGE_VERTEX))
-    GLSLANG_STAGE_TESSCONTROL_MASK = (1 shl ord(GLSLANG_STAGE_TESSCONTROL))
-    GLSLANG_STAGE_TESSEVALUATION_MASK = (1 shl ord(GLSLANG_STAGE_TESSEVALUATION))
-    GLSLANG_STAGE_GEOMETRY_MASK = (1 shl ord(GLSLANG_STAGE_GEOMETRY))
-    GLSLANG_STAGE_FRAGMENT_MASK = (1 shl ord(GLSLANG_STAGE_FRAGMENT))
-    GLSLANG_STAGE_COMPUTE_MASK = (1 shl ord(GLSLANG_STAGE_COMPUTE))
-    GLSLANG_STAGE_RAYGEN_MASK = (1 shl ord(GLSLANG_STAGE_RAYGEN))
-    GLSLANG_STAGE_INTERSECT_MASK = (1 shl ord(GLSLANG_STAGE_INTERSECT))
-    GLSLANG_STAGE_ANYHIT_MASK = (1 shl ord(GLSLANG_STAGE_ANYHIT))
-    GLSLANG_STAGE_CLOSESTHIT_MASK = (1 shl ord(GLSLANG_STAGE_CLOSESTHIT))
-    GLSLANG_STAGE_MISS_MASK = (1 shl ord(GLSLANG_STAGE_MISS))
-    GLSLANG_STAGE_CALLABLE_MASK = (1 shl ord(GLSLANG_STAGE_CALLABLE))
-    GLSLANG_STAGE_TASK_MASK = (1 shl ord(GLSLANG_STAGE_TASK))
-    GLSLANG_STAGE_MESH_MASK = (1 shl ord(GLSLANG_STAGE_MESH))
-    GLSLANG_STAGE_MASK_COUNT
-
-  # EShSource counterpart
-  glslang_source_t* {.size: sizeof(cint).} = enum
-    GLSLANG_SOURCE_NONE
-    GLSLANG_SOURCE_GLSL
-    GLSLANG_SOURCE_HLSL
-    GLSLANG_SOURCE_COUNT
-
-  # EShClient counterpart
-  glslang_client_t* {.size: sizeof(cint).} = enum
-    GLSLANG_CLIENT_NONE
-    GLSLANG_CLIENT_VULKAN
-    GLSLANG_CLIENT_OPENGL
-    GLSLANG_CLIENT_COUNT
-
-  # EShTargetLanguage counterpart
-  glslang_target_language_t* {.size: sizeof(cint).} = enum
-    GLSLANG_TARGET_NONE
-    GLSLANG_TARGET_SPV
-    GLSLANG_TARGET_COUNT
-
-  # SH_TARGET_ClientVersion counterpart
-  glslang_target_client_version_t* {.size: sizeof(cint).} = enum
-    GLSLANG_TARGET_CLIENT_VERSION_COUNT = 5
-    GLSLANG_TARGET_OPENGL_450 = 450
-    GLSLANG_TARGET_VULKAN_1_0 = (1 shl 22)
-    GLSLANG_TARGET_VULKAN_1_1 = (1 shl 22) or (1 shl 12)
-    GLSLANG_TARGET_VULKAN_1_2 = (1 shl 22) or (2 shl 12)
-    GLSLANG_TARGET_VULKAN_1_3 = (1 shl 22) or (3 shl 12)
-
-  # SH_TARGET_LanguageVersion counterpart
-  glslang_target_language_version_t* {.size: sizeof(cint).} = enum
-      GLSLANG_TARGET_LANGUAGE_VERSION_COUNT = 7
-      GLSLANG_TARGET_SPV_1_0 = (1 shl 16)
-      GLSLANG_TARGET_SPV_1_1 = (1 shl 16) or (1 shl 8)
-      GLSLANG_TARGET_SPV_1_2 = (1 shl 16) or (2 shl 8)
-      GLSLANG_TARGET_SPV_1_3 = (1 shl 16) or (3 shl 8)
-      GLSLANG_TARGET_SPV_1_4 = (1 shl 16) or (4 shl 8)
-      GLSLANG_TARGET_SPV_1_5 = (1 shl 16) or (5 shl 8)
-      GLSLANG_TARGET_SPV_1_6 = (1 shl 16) or (6 shl 8)
-
-  # EShExecutable counterpart
-  glslang_executable_t* {.size: sizeof(cint).} = enum
-    GLSLANG_EX_VERTEX_FRAGMENT
-    GLSLANG_EX_FRAGMENT
-
-  # EShOptimizationLevel counterpart
-  # This enum is not used in the current C interface, but could be added at a later date.
-  # GLSLANG_OPT_NONE is the current default.
-  glslang_optimization_level_t* {.size: sizeof(cint).} = enum
-    GLSLANG_OPT_NO_GENERATION
-    GLSLANG_OPT_NONE
-    GLSLANG_OPT_SIMPLE
-    GLSLANG_OPT_FULL
-    GLSLANG_OPT_LEVEL_COUNT
-
-  # EShTextureSamplerTransformMode counterpart
-  glslang_texture_sampler_transform_mode_t* {.size: sizeof(cint).} = enum
-    GLSLANG_TEX_SAMP_TRANS_KEEP
-    GLSLANG_TEX_SAMP_TRANS_UPGRADE_TEXTURE_REMOVE_SAMPLER
-    GLSLANG_TEX_SAMP_TRANS_COUNT
-
-  # EShMessages counterpart
-  glslang_messages_t* {.size: sizeof(cint).} = enum
-    GLSLANG_MSG_DEFAULT_BIT = 0
-    GLSLANG_MSG_RELAXED_ERRORS_BIT = (1 shl 0)
-    GLSLANG_MSG_SUPPRESS_WARNINGS_BIT = (1 shl 1)
-    GLSLANG_MSG_AST_BIT = (1 shl 2)
-    GLSLANG_MSG_SPV_RULES_BIT = (1 shl 3)
-    GLSLANG_MSG_VULKAN_RULES_BIT = (1 shl 4)
-    GLSLANG_MSG_ONLY_PREPROCESSOR_BIT = (1 shl 5)
-    GLSLANG_MSG_READ_HLSL_BIT = (1 shl 6)
-    GLSLANG_MSG_CASCADING_ERRORS_BIT = (1 shl 7)
-    GLSLANG_MSG_KEEP_UNCALLED_BIT = (1 shl 8)
-    GLSLANG_MSG_HLSL_OFFSETS_BIT = (1 shl 9)
-    GLSLANG_MSG_DEBUG_INFO_BIT = (1 shl 10)
-    GLSLANG_MSG_HLSL_ENABLE_16BIT_TYPES_BIT = (1 shl 11)
-    GLSLANG_MSG_HLSL_LEGALIZATION_BIT = (1 shl 12)
-    GLSLANG_MSG_HLSL_DX9_COMPATIBLE_BIT = (1 shl 13)
-    GLSLANG_MSG_BUILTIN_SYMBOL_TABLE_BIT = (1 shl 14)
-    GLSLANG_MSG_ENHANCED = (1 shl 15)
-    GLSLANG_MSG_COUNT
-
-  # EShReflectionOptions counterpart
-  glslang_reflection_options_t* {.size: sizeof(cint).} = enum
-    GLSLANG_REFLECTION_DEFAULT_BIT = 0
-    GLSLANG_REFLECTION_STRICT_ARRAY_SUFFIX_BIT = (1 shl 0)
-    GLSLANG_REFLECTION_BASIC_ARRAY_SUFFIX_BIT = (1 shl 1)
-    GLSLANG_REFLECTION_INTERMEDIATE_IOO_BIT = (1 shl 2)
-    GLSLANG_REFLECTION_SEPARATE_BUFFERS_BIT = (1 shl 3)
-    GLSLANG_REFLECTION_ALL_BLOCK_VARIABLES_BIT = (1 shl 4)
-    GLSLANG_REFLECTION_UNWRAP_IO_BLOCKS_BIT = (1 shl 5)
-    GLSLANG_REFLECTION_ALL_IO_VARIABLES_BIT = (1 shl 6)
-    GLSLANG_REFLECTION_SHARED_STD140_SSBO_BIT = (1 shl 7)
-    GLSLANG_REFLECTION_SHARED_STD140_UBO_BIT = (1 shl 8)
-    GLSLANG_REFLECTION_COUNT
-
-  # EProfile counterpart (from Versions.h)
-  glslang_profile_t* {.size: sizeof(cint).} = enum
-    GLSLANG_BAD_PROFILE = 0
-    GLSLANG_NO_PROFILE = (1 shl 0)
-    GLSLANG_CORE_PROFILE = (1 shl 1)
-    GLSLANG_COMPATIBILITY_PROFILE = (1 shl 2)
-    GLSLANG_ES_PROFILE = (1 shl 3)
-    GLSLANG_PROFILE_COUNT
-
-  # Shader options
-  glslang_shader_options_t* {.size: sizeof(cint).} = enum
-    GLSLANG_SHADER_DEFAULT_BIT = 0
-    GLSLANG_SHADER_AUTO_MAP_BINDINGS = (1 shl 0)
-    GLSLANG_SHADER_AUTO_MAP_LOCATIONS = (1 shl 1)
-    GLSLANG_SHADER_VULKAN_RULES_RELAXED = (1 shl 2)
-    GLSLANG_SHADER_COUNT
-
-  # TResourceType counterpart
-  glslang_resource_type_t* {.size: sizeof(cint).} = enum
-    GLSLANG_RESOURCE_TYPE_SAMPLER
-    GLSLANG_RESOURCE_TYPE_TEXTURE
-    GLSLANG_RESOURCE_TYPE_IMAGE
-    GLSLANG_RESOURCE_TYPE_UBO
-    GLSLANG_RESOURCE_TYPE_SSBO
-    GLSLANG_RESOURCE_TYPE_UAV
-    GLSLANG_RESOURCE_TYPE_COUNT
-
--- a/src/zamikongine/math/matrix.nim	Tue Jan 10 00:24:37 2023 +0700
+++ b/src/zamikongine/math/matrix.nim	Wed Jan 11 00:43:17 2023 +0700
@@ -339,6 +339,48 @@
   m[0, 3], m[1, 3], m[2, 3], m[3, 3],
 ])
 
+func translate2d*[T](x, y: T): Mat33[T] = Mat33[T](data: [
+  T(1), T(0), x,
+  T(0), T(1), y,
+  T(0), T(0), T(1),
+])
+func scale2d*[T](sx, sy: T): Mat33[T] = Mat33[T](data: [
+  sx, T(0), T(0),
+  T(0), sy, T(0),
+  T(0), T(0), T(1),
+])
+func rotate2d*[T](angle: T): Mat33[T] = Mat33[T](data: [
+  cos(angle), -sin(angle), T(0),
+  sin(angle), cos(angle), T(0),
+  T(0), T(0), T(1),
+])
+func translate3d*[T](x, y, z: T): Mat44[T] = Mat44[T](data: [
+  T(1), T(0), T(0), x,
+  T(0), T(1), T(0), y,
+  T(0), T(0), T(1), z,
+  T(0), T(0), T(0), T(1),
+])
+func scale3d*[T](sx, sy, sz: T): Mat44[T] = Mat44[T](data: [
+  sx, T(0), T(0), T(0),
+  T(0), sy, T(0), T(0),
+  T(0), T(0), sz, T(0),
+  T(0), T(0),  T(0), T(1),
+])
+func rotate3d*[T](angle: T, a: Vec3[T]): Mat44[T] =
+  let
+    cosa = cos(angle)
+    sina = sin(angle)
+    x = a.x
+    y = a.y
+    z = a.z
+  Mat44[T](data: [
+    x * x * (1 - cosa) + cosa,     y * x * (1 - cosa) - z * sina, z * x * (1 - cosa) + y * sina, T(0),
+    x * y * (1 - cosa) + z * sina, y * y * (1 - cosa) + cosa,     z * y * (1 - cosa) - x * sina, T(0),
+    x * z * (1 - cosa) - y * sina, y * z * (1 - cosa) + x * sina, z * z * (1 - cosa) + cosa,     T(0),
+    T(0),                             T(0),                             T(0),                             1,
+  ])
+
+
 # call e.g. Mat32[int]().randomized() to get a random matrix
 template makeRandomInit(mattype: typedesc) =
     proc randomized*[T: SomeInteger](m: mattype[T]): mattype[T] =
--- a/src/zamikongine/shader.nim	Tue Jan 10 00:24:37 2023 +0700
+++ b/src/zamikongine/shader.nim	Wed Jan 11 00:43:17 2023 +0700
@@ -1,10 +1,11 @@
+import std/osproc
+import std/strformat
 import std/strutils
 import std/tables
 
 import ./vulkan_helpers
 import ./vulkan
 import ./vertex
-import ./glslang/glslang
 
 type
   ShaderProgram* = object
@@ -12,15 +13,38 @@
     programType*: VkShaderStageFlagBits
     shader*: VkPipelineShaderStageCreateInfo
 
+func stage2string(stage: VkShaderStageFlagBits): string =
+  case stage
+  of VK_SHADER_STAGE_VERTEX_BIT: "vert"
+  of VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT: "tesc"
+  of VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT: "tese"
+  of VK_SHADER_STAGE_GEOMETRY_BIT: "geom"
+  of VK_SHADER_STAGE_FRAGMENT_BIT: "frag"
+  of VK_SHADER_STAGE_ALL_GRAPHICS: ""
+  of VK_SHADER_STAGE_COMPUTE_BIT: "comp"
+  of VK_SHADER_STAGE_ALL: ""
+
+proc compileGLSLToSPIRV(stage: VkShaderStageFlagBits, shaderSource: string, entrypoint: string): seq[uint32] =
+  let stagename = stage2string(stage)
+  let (output, exitCode) = execCmdEx(command=fmt"./glslangValidator --entry-point {entrypoint} -V --stdin -S {stagename}", input=shaderSource)
+  if exitCode != 0:
+    raise newException(Exception, output)
+  let shaderbinary = readFile fmt"{stagename}.spv"
+  var i = 0
+  while i < shaderbinary.len:
+    result.add(
+      (uint32(shaderbinary[i + 0]) shl  0) or
+      (uint32(shaderbinary[i + 1]) shl  8) or
+      (uint32(shaderbinary[i + 2]) shl 16) or
+      (uint32(shaderbinary[i + 3]) shl 24)
+    )
+    i += 4
+
 proc initShaderProgram*(device: VkDevice, programType: VkShaderStageFlagBits, shader: string, entryPoint: string="main"): ShaderProgram =
   result.entryPoint = entryPoint
   result.programType = programType
 
-  const VK_GLSL_MAP = {
-    VK_SHADER_STAGE_VERTEX_BIT: GLSLANG_STAGE_VERTEX,
-    VK_SHADER_STAGE_FRAGMENT_BIT: GLSLANG_STAGE_FRAGMENT,
-  }.toTable()
-  var code = compileGLSLToSPIRV(VK_GLSL_MAP[result.programType], shader, "<memory-shader>")
+  var code = compileGLSLToSPIRV(result.programType, shader, result.entryPoint)
   var createInfo = VkShaderModuleCreateInfo(
     sType: VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
     codeSize: uint(code.len * sizeof(uint32)),
--- a/src/zamikongine/vulkan_helpers.nim	Tue Jan 10 00:24:37 2023 +0700
+++ b/src/zamikongine/vulkan_helpers.nim	Wed Jan 11 00:43:17 2023 +0700
@@ -149,9 +149,11 @@
 
   when ENABLEVULKANVALIDATIONLAYERS:
     const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring]
-    for layer in desiredLayers:
-      if $layer in availableLayers:
-        usableLayers.add(layer)
+  else:
+    const desiredLayers = ["VK_LAYER_MESA_overlay".cstring]
+  for layer in desiredLayers:
+    if $layer in availableLayers:
+      usableLayers.add(layer)
 
   echo "Available validation layers: ", availableLayers
   echo "Using validation layers: ", usableLayers