changeset 134:e6c7973d8525

add: remove a few warning, improve a few things
author Sam <sam@basx.dev>
date Thu, 20 Apr 2023 23:45:36 +0700
parents 9f2c178beb60
children 250e1dcbfec9
files src/semicongine/config.nim src/semicongine/engine.nim src/semicongine/mesh.nim src/semicongine/renderer.nim src/semicongine/vulkan/renderpass.nim src/semicongine/vulkan/swapchain.nim
diffstat 6 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/config.nim	Thu Apr 20 21:59:52 2023 +0700
+++ b/src/semicongine/config.nim	Thu Apr 20 23:45:36 2023 +0700
@@ -1,3 +1,4 @@
+import std/logging
 import std/parsecfg
 import std/strutils
 import std/sequtils
@@ -112,3 +113,7 @@
   var thethread: Thread[void]
   createThread(thethread, configFileWatchdog)
 
+if DEBUG:
+  setLogFilter(lvlAll)
+else:
+  setLogFilter(lvlWarn)
--- a/src/semicongine/engine.nim	Thu Apr 20 21:59:52 2023 +0700
+++ b/src/semicongine/engine.nim	Thu Apr 20 23:45:36 2023 +0700
@@ -40,9 +40,10 @@
   checkVkResult engine.device.vk.vkDeviceWaitIdle()
   engine.renderer.destroy()
   engine.device.destroy()
-  engine.debugger.destroy()
+  if engine.debugger.messenger.valid:
+    engine.debugger.destroy()
+  engine.window.destroy()
   engine.instance.destroy()
-  engine.window.destroy()
   engine.running = false
 
 
--- a/src/semicongine/mesh.nim	Thu Apr 20 21:59:52 2023 +0700
+++ b/src/semicongine/mesh.nim	Thu Apr 20 23:45:36 2023 +0700
@@ -112,6 +112,11 @@
 func getRawData*(mesh: Mesh, attribute: string): (pointer, uint32) =
   mesh.data[attribute].getRawData()
 
+proc setMeshData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) =
+  assert not (attribute in mesh.data)
+  mesh.data[attribute] = DataList(thetype: getDataType[T]())
+  setValues(mesh.data[attribute], data)
+
 proc setInstanceData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) =
   assert uint32(data.len) == mesh.instanceCount
   assert not (attribute in mesh.data)
--- a/src/semicongine/renderer.nim	Thu Apr 20 21:59:52 2023 +0700
+++ b/src/semicongine/renderer.nim	Thu Apr 20 23:45:36 2023 +0700
@@ -1,5 +1,4 @@
 import std/options
-import std/sequtils
 import std/tables
 import std/strformat
 import std/logging
@@ -12,7 +11,6 @@
 import ./vulkan/physicaldevice
 import ./vulkan/renderpass
 import ./vulkan/swapchain
-import ./vulkan/syncing
 
 import ./entity
 import ./mesh
--- a/src/semicongine/vulkan/renderpass.nim	Thu Apr 20 21:59:52 2023 +0700
+++ b/src/semicongine/vulkan/renderpass.nim	Thu Apr 20 23:45:36 2023 +0700
@@ -71,12 +71,12 @@
   vertexCode: ShaderCode,
   fragmentCode: ShaderCode,
   inFlightFrames: int = 2,
-  format = VkFormat(0),
+  format = VK_FORMAT_UNDEFINED ,
   clearColor=Vec4f([0.8'f32, 0.8'f32, 0.8'f32, 1'f32])
 ): RenderPass =
   assert device.vk.valid
   var theformat = format
-  if theformat == VkFormat(0):
+  if theformat == VK_FORMAT_UNDEFINED:
     theformat = device.physicalDevice.getSurfaceFormats().filterSurfaceFormat().format
   var
     attachments = @[VkAttachmentDescription(
--- a/src/semicongine/vulkan/swapchain.nim	Thu Apr 20 21:59:52 2023 +0700
+++ b/src/semicongine/vulkan/swapchain.nim	Thu Apr 20 23:45:36 2023 +0700
@@ -7,7 +7,6 @@
 import ./device
 import ./physicaldevice
 import ./image
-import ./renderpass
 import ./framebuffer
 import ./commandbuffer
 import ./syncing