changeset 598:67b44ba428d1

add: some cleanup, discovered bug
author Sam <sam@basx.dev>
date Fri, 21 Apr 2023 00:29:09 +0700
parents fdae5f50fa00
children 5eadc1e1d6d8
files examples/E02_squares.nim src/semicongine/gpu_data.nim src/semicongine/renderer.nim src/semicongine/vulkan.nim src/semicongine/vulkan/vertex.nim
diffstat 5 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/examples/E02_squares.nim	Thu Apr 20 23:46:22 2023 +0700
+++ b/examples/E02_squares.nim	Fri Apr 21 00:29:09 2023 +0700
@@ -47,7 +47,7 @@
   const
     vertexInput = @[
       attr[Vec3f]("position", memoryLocation=VRAM),
-      attr[Vec3f]("color", memoryLocation=VRAM), # TODO: VRAMVisible
+      attr[Vec3f]("color", memoryLocation=VRAM),
       attr[uint32]("index", memoryLocation=VRAM),
     ]
     vertexOutput = @[attr[Vec3f]("outcolor")]
@@ -80,6 +80,11 @@
     colors=colors,
   )
   setMeshData[uint32](squaremesh, "index", iValues.toSeq)
+  var i = 0'u64
+  var (p, l) = squaremesh.getRawData("color")
+  while i < uint64(l):
+    echo (cast[ptr float32]((cast[uint64](p) + i)))[]
+    inc i
 
   var myengine = initEngine("Squares")
   myengine.setRenderer(myengine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode))
--- a/src/semicongine/gpu_data.nim	Thu Apr 20 23:46:22 2023 +0700
+++ b/src/semicongine/gpu_data.nim	Fri Apr 21 00:29:09 2023 +0700
@@ -787,8 +787,7 @@
   if group.len == 0:
     return @[]
   var i = 0'u32
-  for attributes in group.groupByMemoryLocation().values:
-    for attribute in attributes:
+  for attribute in group:
       result.add &"layout(location = {i}) in {attribute.thetype.glslType} {attribute.name};"
       for j in 0 ..< attribute.thetype.numberOfVertexInputAttributeDescriptors:
         i += attribute.thetype.nLocationSlots
--- a/src/semicongine/renderer.nim	Thu Apr 20 23:46:22 2023 +0700
+++ b/src/semicongine/renderer.nim	Fri Apr 21 00:29:09 2023 +0700
@@ -72,6 +72,8 @@
       mappable=false,
     )
 
+  # TODO: groupByMemoryLocation does bad stuff when we have mixed types of memory locations for different mesh attributes
+
   # one vertex data buffer per memory location
   var perLocationOffsets: Table[MemoryLocation, uint64]
   for location, attributes in inputs.groupByMemoryLocation().pairs:
--- a/src/semicongine/vulkan.nim	Thu Apr 20 23:46:22 2023 +0700
+++ b/src/semicongine/vulkan.nim	Fri Apr 21 00:29:09 2023 +0700
@@ -28,9 +28,6 @@
 import ./vulkan/shader
 export shader
 
-import ./vulkan/vertex
-export vertex
-
 import ./vulkan/descriptor
 export descriptor
 
--- a/src/semicongine/vulkan/vertex.nim	Thu Apr 20 23:46:22 2023 +0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-# add pragma to fields of the VertexType that represent per instance attributes
-template PerInstance*() {.pragma.}
-