comparison semiconginev2/rendering/renderer.nim @ 1255:2b5ca798f6d6

did: make example town loadable and renderable, yay!
author sam <sam@basx.dev>
date Sun, 28 Jul 2024 00:17:34 +0700
parents b0f4c8ccd49a
children
comparison
equal deleted inserted replaced
1254:b0f4c8ccd49a 1255:2b5ca798f6d6
605 static: 605 static:
606 hasBoundDescriptorSets = false 606 hasBoundDescriptorSets = false
607 607
608 proc assertCanRenderMesh(TShader, TMesh, TInstance: typedesc) = 608 proc assertCanRenderMesh(TShader, TMesh, TInstance: typedesc) =
609 for attrName, attrValue in default(TShader).fieldPairs: 609 for attrName, attrValue in default(TShader).fieldPairs:
610 if hasCustomPragma(attrValue, VertexAttribute): 610 when hasCustomPragma(attrValue, VertexAttribute):
611 var foundAttr = false 611 var foundAttr = false
612 for meshAttrName, meshAttrValue in default(TMesh).fieldPairs: 612 for meshAttrName, meshAttrValue in default(TMesh).fieldPairs:
613 if attrName == meshAttrName: 613 when attrName == meshAttrName:
614 assert typeof(meshAttrValue) is GPUArray, "Mesh attribute '" & attrName & "' must be a GPUArray" 614 assert typeof(meshAttrValue) is GPUArray, "Mesh attribute '" & attrName & "' must be a GPUArray"
615 assert typeof(attrValue) is elementType(meshAttrValue.data), "Type of shader attribute and mesh attribute '" & attrName & "' is not the same" 615 assert typeof(attrValue) is elementType(meshAttrValue.data), "Type of shader attribute and mesh attribute '" & attrName & "' is not the same"
616 foundAttr = true 616 foundAttr = true
617 assert foundAttr, "Attribute '" & attrName & "' is not provided in mesh type '" & name(TMesh) & "'" 617 assert foundAttr, "Attribute '" & attrName & "' is not provided in mesh type '" & name(TMesh) & "'"
618 if hasCustomPragma(attrValue, InstanceAttribute): 618 if hasCustomPragma(attrValue, InstanceAttribute):