changeset 789:fca6f069d59e

did: some cleanup
author Sam <sam@basx.dev>
date Fri, 25 Aug 2023 01:14:04 +0700
parents 2d8a92171c9e
children a979e5c581de
files src/semicongine/renderer.nim src/semicongine/scene.nim tests/test_vulkan_wrapper.nim
diffstat 3 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/renderer.nim	Fri Aug 25 01:09:23 2023 +0700
+++ b/src/semicongine/renderer.nim	Fri Aug 25 01:14:04 2023 +0700
@@ -165,6 +165,7 @@
   var indexBufferOffset = 0
   for hint in MemoryPerformanceHint:
     perLocationOffsets[hint] = 0
+
   for (meshIndex, mesh) in enumerate(scene.meshes):
     for attribute in inputs:
       scenedata.vertexBufferOffsets[(meshIndex, attribute.name)] = perLocationOffsets[attribute.memoryPerformanceHint]
@@ -173,7 +174,7 @@
       if perLocationOffsets[attribute.memoryPerformanceHint] mod VERTEX_ATTRIB_ALIGNMENT != 0:
         perLocationOffsets[attribute.memoryPerformanceHint] += VERTEX_ATTRIB_ALIGNMENT - (perLocationOffsets[attribute.memoryPerformanceHint] mod VERTEX_ATTRIB_ALIGNMENT)
 
-    # fill offsets (as sequence corresponds to shader input binding)
+    # fill offsets per pipeline (as sequence corresponds to shader input binding)
     var offsets: Table[VkPipeline, seq[(string, MemoryPerformanceHint, int)]]
     for subpass_i in 0 ..< renderer.renderPass.subpasses.len:
       for materialType, pipeline in renderer.renderPass.subpasses[subpass_i].pipelines.pairs:
@@ -181,6 +182,7 @@
         for attribute in pipeline.inputs:
           offsets[pipeline.vk].add (attribute.name, attribute.memoryPerformanceHint, scenedata.vertexBufferOffsets[(meshIndex, attribute.name)])
 
+    # create drawables
     let indexed = mesh.indexType != MeshIndexType.None
     var drawable = Drawable(
       elementCount: if indexed: mesh.indicesCount else: mesh.vertexCount,
--- a/src/semicongine/scene.nim	Fri Aug 25 01:09:23 2023 +0700
+++ b/src/semicongine/scene.nim	Fri Aug 25 01:14:04 2023 +0700
@@ -12,8 +12,6 @@
   Scene* = object
     name*: string
     shaderGlobals*: Table[string, DataList]
-    transformAttribute*: string = "transform"
-    materialIndexAttribute*: string = "materialIndex"
     meshes*: seq[Mesh]
 
 func addShaderGlobal*[T](scene: var Scene, name: string, data: T) =
--- a/tests/test_vulkan_wrapper.nim	Fri Aug 25 01:09:23 2023 +0700
+++ b/tests/test_vulkan_wrapper.nim	Fri Aug 25 01:14:04 2023 +0700
@@ -198,15 +198,14 @@
 
   # INIT SCENES
   var scenes = [
-    # Scene(name: "simple", meshes: scene_simple()),
-    # Scene(name: "different mesh types", meshes: scene_different_mesh_types()),
-    # Scene(name: "primitives", meshes: scene_primitives()),
-    # Scene(name: "flag", meshes: scene_flag()),
-    # Scene(name: "multimaterial", meshes: scene_multi_material(), materialIndexAttribute: ""),
+    Scene(name: "simple", meshes: scene_simple()),
+    Scene(name: "different mesh types", meshes: scene_different_mesh_types()),
+    Scene(name: "primitives", meshes: scene_primitives()),
+    Scene(name: "flag", meshes: scene_flag()),
     Scene(name: "multimaterial", meshes: scene_multi_material()),
   ]
 
-  scenes[0].addShaderGlobal("color", newVec4f(1, 0, 0, 1))
+  scenes[4].addShaderGlobal("color", newVec4f(1, 0, 0, 1))
   for scene in scenes.mitems:
     scene.addShaderGlobal("time", 0.0'f32)
     engine.addScene(scene)