changeset 795:4a15d94d9418

fix: remaining tests and an issue with updating uniforms
author Sam <sam@basx.dev>
date Mon, 04 Sep 2023 00:48:00 +0700
parents 59c54c4486c4
children 8084252b807a
files src/semicongine/renderer.nim tests/test_materials.nim tests/test_vulkan_wrapper.nim
diffstat 3 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/semicongine/renderer.nim	Mon Sep 04 00:31:17 2023 +0700
+++ b/src/semicongine/renderer.nim	Mon Sep 04 00:48:00 2023 +0700
@@ -387,11 +387,11 @@
           debug &"  update uniform {uniform.name} with value: {value}"
           let (pdata, size) = value.getRawData()
           if dirty.contains(uniform.name) or forceAll: # only update if necessary
-            if forceAll: # need to update all in-flight frames, when forced to do all
-              for buffer in renderer.scenedata[scene].uniformBuffers[pipeline.vk]:
-                buffer.setData(pdata, size, offset)
-            else:
-              renderer.scenedata[scene].uniformBuffers[pipeline.vk][renderer.swapchain.currentInFlight].setData(pdata, size, offset)
+            # TODO: technically we would only need to update the uniform buffer of the current
+            # frameInFlight, but we don't track for which frame the shaderglobals are no longer dirty
+            # therefore we have to update the uniform values in all buffers, of all inFlightframes (usually 2)
+            for buffer in renderer.scenedata[scene].uniformBuffers[pipeline.vk]:
+              buffer.setData(pdata, size, offset)
           offset += size
   scene.clearDirtyShaderGlobals()
 
--- a/tests/test_materials.nim	Mon Sep 04 00:31:17 2023 +0700
+++ b/tests/test_materials.nim	Mon Sep 04 00:48:00 2023 +0700
@@ -38,8 +38,8 @@
       ],
       uniforms=[attr[float32]("test2", arrayCount=2)],
       samplers = @[
-        attr[Sampler2DType]("tex1", arrayCount=2),
-        attr[Sampler2DType]("tex2", arrayCount=2),
+        attr[Texture]("tex1", arrayCount=2),
+        attr[Texture]("tex2", arrayCount=2),
       ],
       outputs=[attr[Vec4f]("color")],
       vertexCode="""
--- a/tests/test_vulkan_wrapper.nim	Mon Sep 04 00:31:17 2023 +0700
+++ b/tests/test_vulkan_wrapper.nim	Mon Sep 04 00:48:00 2023 +0700
@@ -169,7 +169,7 @@
       ],
       outputs=[attr[Vec4f]("color")],
       samplers=[
-        attr[Sampler2DType]("my_little_texture")
+        attr[Texture]("my_little_texture")
       ],
       vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = color;""",
       fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;",