# HG changeset patch # User Sam # Date 1682011749 -25200 # Node ID ac2b6777c5dbd85f7561e770666d17575c2c5829 # Parent fc5db4f1f94eb40af40f688ca018970a3d2992ff add: some cleanup, discovered bug diff -r fc5db4f1f94e -r ac2b6777c5db examples/E02_squares.nim --- 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)) diff -r fc5db4f1f94e -r ac2b6777c5db src/semicongine/gpu_data.nim --- 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 diff -r fc5db4f1f94e -r ac2b6777c5db src/semicongine/renderer.nim --- 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: diff -r fc5db4f1f94e -r ac2b6777c5db src/semicongine/vulkan.nim --- 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 diff -r fc5db4f1f94e -r ac2b6777c5db src/semicongine/vulkan/vertex.nim --- 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.} -