changeset 1284:feb52b1c18e0

fixing stuff
author sam <sam@basx.dev>
date Mon, 29 Jul 2024 20:09:04 +0700
parents 0369fa1ffbd9
children 6d16003406fb
files semicongine/rendering/renderer.nim semicongine/rendering/shaders.nim
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/rendering/renderer.nim	Mon Jul 29 16:50:50 2024 +0700
+++ b/semicongine/rendering/renderer.nim	Mon Jul 29 20:09:04 2024 +0700
@@ -638,8 +638,9 @@
     for attrName, attrValue in default(TShader).fieldPairs():
       if attrValue.hasCustomPragma(DescriptorSets):
         hasDescriptorSets = true
-    if hasDescriptorSets:
-      assert hasBoundDescriptorSets, "Shader uses descriptor sets, but none are bound"
+    # TODO: fix this, not working as intended, seems to depend on scope
+    # if hasDescriptorSets:
+      # assert hasBoundDescriptorSets, "Shader uses descriptor sets, but none are bound"
 
   var vertexBuffers: seq[VkBuffer]
   var vertexBuffersOffsets: seq[uint64]
--- a/semicongine/rendering/shaders.nim	Mon Jul 29 16:50:50 2024 +0700
+++ b/semicongine/rendering/shaders.nim	Mon Jul 29 20:09:04 2024 +0700
@@ -163,7 +163,7 @@
     elif hasCustomPragma(value, DescriptorSets):
       assert not sawDescriptorSets, "Only one field with pragma DescriptorSets allowed per shader"
       assert typeof(value) is tuple, "Descriptor field '" & fieldname & "' must be of type tuple"
-      assert tupleLen(typeof(value)) <= MAX_DESCRIPTORSETS, typetraits.name(TShader) & ": maximum " & $MAX_DESCRIPTORSETS & " allowed"
+      assert tupleLen(value) <= MAX_DESCRIPTORSETS, typetraits.name(TShader) & ": maximum " & $MAX_DESCRIPTORSETS & " allowed"
       sawDescriptorSets = true
       var descriptorSetIndex = 0
       for descriptor in value.fields:
@@ -224,7 +224,9 @@
         pushConstants.add "  " & glslType(constFieldValue) & " " & constFieldName & ";"
       pushConstants.add "} " & fieldname & ";"
     else:
-      {.error: "Unsupported shader field '" & typetraits.name(TShader) & "." & fieldname & "' of type " & typetraits.name(typeof(value)).}
+      static:
+        echo "Unsupported shader field '" & typetraits.name(TShader) & "." & fieldname & "' of type " & typetraits.name(typeof(value))
+      {.error: "Unsupported shader field".}
 
   result[0] = (@[&"#version {GLSL_VERSION}", "#extension GL_EXT_scalar_block_layout : require", ""] &
     vsInput &
@@ -528,6 +530,9 @@
     addr(result.vk)
   )
 
+func layout*(pipeline: Pipeline, level: int): VkDescriptorSetLayout =
+  pipeline.descriptorSetLayouts[level]
+
 template withPipeline*(commandbuffer: VkCommandBuffer, pipeline: Pipeline, body: untyped): untyped =
   block:
     vkCmdBindPipeline(commandbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.vk)