# HG changeset patch # User Sam # Date 1682011749 -25200 # Node ID 67b44ba428d1a51a13373020d9c0e7dc28ef46f6 # Parent fdae5f50fa00531cbe0702f2bbdf64a1d6bf361f add: some cleanup, discovered bug diff -r fdae5f50fa00 -r 67b44ba428d1 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 fdae5f50fa00 -r 67b44ba428d1 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 fdae5f50fa00 -r 67b44ba428d1 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 fdae5f50fa00 -r 67b44ba428d1 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 fdae5f50fa00 -r 67b44ba428d1 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.} -