changeset 469:ed49f1cdd8b7

add: a few missing changes
author Sam <sam@basx.dev>
date Thu, 22 Dec 2022 19:35:54 +0700
parents 2ee12af72659
children ca0ae5a7cf2f 9eeaeb35eb1c
files .gitignore Makefile README.md src/engine.nim
diffstat 4 files changed, 33 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.gitignore	Thu Dec 22 19:33:00 2022 +0700
+++ b/.gitignore	Thu Dec 22 19:35:54 2022 +0700
@@ -1,3 +1,6 @@
 nimcache/
 nimblecache/
 htmldocs/
+
+build/
+thirdparty/
--- a/Makefile	Thu Dec 22 19:33:00 2022 +0700
+++ b/Makefile	Thu Dec 22 19:35:54 2022 +0700
@@ -2,6 +2,7 @@
 COMPILE_OPTIONS := --path:src --mm:orc --experimental:strictEffects --threads:on
 DEBUG_OPTIONS := --debugger:native --checks:on --assertions:on
 RELEASE_OPTIONS := -d:release --checks:off --assertions:off
+WINDOWS_OPTIONS := -d:mingw
 
 # build
 build/debug/linux/test: ${SOURCES}
@@ -12,12 +13,15 @@
 	nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} -o:$@ examples/test.nim
 build/debug/windows/test:  ${SOURCES}
 	mkdir -p $$( dirname $@ )
-	nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} -o:$@ examples/test.nim
+	nim c ${COMPILE_OPTIONS} ${DEBUG_OPTIONS} ${WINDOWS_OPTIONS} -o:$@ examples/test.nim
 build/release/windows/test: ${SOURCES}
 	mkdir -p $$( dirname $@ )
-	nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} -o:$@ examples/test.nim
+	nim c ${COMPILE_OPTIONS} ${RELEASE_OPTIONS} ${WINDOWS_OPTIONS} -o:$@ examples/test.nim
 
-build_all: build/debug/linux/test build/release/linux/test build/debug/windows/test build/release/windows/test
+build_all_linux: build/debug/linux/test build/release/linux/test
+build_all_windows: build/debug/windows/test build/release/windows/test
+
+build_all: build_all_linux build_all_windows
 
 # publish
 publish_linux_debug: build/debug/linux/test
@@ -37,7 +41,7 @@
 thirdparty/lib/glslang/linux_debug:
 	mkdir -p $@
 	wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Debug.zip
-	uzip glslang-master-linux-Debug.zip
+	unzip glslang-master-linux-Debug.zip
 thirdparty/lib/glslang/linux_release:
 	mkdir -p $@
 	wget --directory-prefix=$@ https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-linux-Release.zip
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Thu Dec 22 19:35:54 2022 +0700
@@ -0,0 +1,3 @@
+Hi there
+
+This is currently only for my test codes, maybe, one far day, it will become a small rendering engine.
--- a/src/engine.nim	Thu Dec 22 19:33:00 2022 +0700
+++ b/src/engine.nim	Thu Dec 22 19:35:54 2022 +0700
@@ -137,23 +137,24 @@
       height: min(max(uint32(height), capabilities.minImageExtent.height), capabilities.maxImageExtent.height),
     )
 
-proc setupDebugLog(instance: VkInstance): VkDebugUtilsMessengerEXT =
-  var createInfo = VkDebugUtilsMessengerCreateInfoEXT(
-    sType: VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
-    messageSeverity: VkDebugUtilsMessageSeverityFlagsEXT(
-      ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) or
-      ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) or
-      ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
-    ),
-    messageType: VkDebugUtilsMessageTypeFlagsEXT(
-      ord(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) or
-      ord(VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) or
-      ord(VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)
-    ),
-    pfnUserCallback: debugCallback,
-    pUserData: nil,
-  )
-  checkVkResult instance.vkCreateDebugUtilsMessengerEXT(addr(createInfo), nil, addr(result))
+when not defined(release):
+  proc setupDebugLog(instance: VkInstance): VkDebugUtilsMessengerEXT =
+    var createInfo = VkDebugUtilsMessengerCreateInfoEXT(
+      sType: VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
+      messageSeverity: VkDebugUtilsMessageSeverityFlagsEXT(
+        ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) or
+        ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) or
+        ord(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
+      ),
+      messageType: VkDebugUtilsMessageTypeFlagsEXT(
+        ord(VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) or
+        ord(VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) or
+        ord(VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)
+      ),
+      pfnUserCallback: debugCallback,
+      pUserData: nil,
+    )
+    checkVkResult instance.vkCreateDebugUtilsMessengerEXT(addr(createInfo), nil, addr(result))
 
 proc setupVulkanDeviceAndQueues(instance: VkInstance, surface: VkSurfaceKHR): Device =
   let usableDevices = instance.getAllPhysicalDevices(surface).filterForDevice()
@@ -468,7 +469,7 @@
 
   # create vulkan instance
   result.vulkan.instance = createVulkanInstance(VULKAN_VERSION)
-  when ENABLEVULKANVALIDATIONLAYERS:
+  when not defined(release):
     result.vulkan.debugMessenger = result.vulkan.instance.setupDebugLog()
   result.vulkan.surface = result.vulkan.instance.createVulkanSurface(result.window)
   result.vulkan.device = result.vulkan.instance.setupVulkanDeviceAndQueues(result.vulkan.surface)