# HG changeset patch # User sam # Date 1724477626 -25200 # Node ID 5ca89802a7465a6cedeb9f0f11f822b5f55645f4 # Parent f2ff6f624932e726608c77dde3c1e6a333b02acd did: improve error messages diff -r f2ff6f624932 -r 5ca89802a746 semicongine/image.nim --- a/semicongine/image.nim Thu Aug 22 22:31:05 2024 +0700 +++ b/semicongine/image.nim Sat Aug 24 12:33:46 2024 +0700 @@ -1,4 +1,5 @@ import std/os +import std/typetraits import std/streams import std/strutils @@ -49,6 +50,13 @@ proc `=copy`[S, T](dest: var ImageObject[S, T], source: ImageObject[S, T]) {.error.} +func `$`*[S, IsArray](img: ImageObject[S, IsArray]): string = + let pixelTypeName = S.name + if IsArray == false: + &"{img.width}x{img.height} {pixelTypeName}" + else: + &"{img.width}x{img.height}[{img.nLayers}] {pixelTypeName}" + func copy*[S, T](img: ImageObject[S, T]): ImageObject[S, T] = for bf, rf in fields(img, result): rf = bf diff -r f2ff6f624932 -r 5ca89802a746 semicongine/rendering/renderer.nim --- a/semicongine/rendering/renderer.nim Thu Aug 22 22:31:05 2024 +0700 +++ b/semicongine/rendering/renderer.nim Sat Aug 24 12:33:46 2024 +0700 @@ -618,8 +618,7 @@ assert typeof(meshAttrValue) is GPUArray, "Mesh attribute '" & attrName & "' must be a GPUArray" assert typeof(attrValue) is elementType(meshAttrValue.data), - "Type of shader attribute and mesh attribute '" & attrName & - "' is not the same" + "Type of shader attribute and mesh attribute '" & attrName & "' is not the same (" & typeof(attrValue).name & " and " & elementType(meshAttrValue.data).name & ")" foundAttr = true assert foundAttr, "Attribute '" & attrName & "' is not provided in mesh type '" & name(TMesh) & "'" diff -r f2ff6f624932 -r 5ca89802a746 semicongine/rendering/shaders.nim --- a/semicongine/rendering/shaders.nim Thu Aug 22 22:31:05 2024 +0700 +++ b/semicongine/rendering/shaders.nim Sat Aug 24 12:33:46 2024 +0700 @@ -249,9 +249,9 @@ elif hasCustomPragma(value, DescriptorSet): let setIndex = value.getCustomPragmaVal(DescriptorSet) assert not sawDescriptorSets[setIndex], - "Only one DescriptorSet per index is allowed per shader" + TShader.name & ": Only one DescriptorSet per index is allowed per shader" assert typeof(value) is object, - "Descriptor field '" & fieldname & "' must be of type object" + TShader.name & "Descriptor field '" & fieldname & "' must be of type object" assert setIndex < MAX_DESCRIPTORSETS, typetraits.name(TShader) & ": maximum " & $MAX_DESCRIPTORSETS & " descriptor sets allowed"