# HG changeset patch # User Sam # Date 1692900844 -25200 # Node ID fca6f069d59e0c5884514fe823bea545b45f2686 # Parent 2d8a92171c9e2eaee1566803e61cb39ce6c91dda did: some cleanup diff -r 2d8a92171c9e -r fca6f069d59e src/semicongine/renderer.nim --- 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, diff -r 2d8a92171c9e -r fca6f069d59e src/semicongine/scene.nim --- 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) = diff -r 2d8a92171c9e -r fca6f069d59e tests/test_vulkan_wrapper.nim --- 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)