# HG changeset patch # User Sam # Date 1677065761 -25200 # Node ID fa1b6107deae60d304e67c4776f7ecac3e5eea97 # Parent 637da715b604a49abd99145ca2cf1bc8105295c3 did: final cleanup for now diff -r 637da715b604 -r fa1b6107deae src/vulkan_api/vulkan_api_generator.nim --- a/src/vulkan_api/vulkan_api_generator.nim Wed Feb 22 18:22:20 2023 +0700 +++ b/src/vulkan_api/vulkan_api_generator.nim Wed Feb 22 18:36:01 2023 +0700 @@ -10,9 +10,6 @@ import std/xmlparser import std/xmltree -type - FileContent = seq[string] - const TYPEMAP = { "void": "void", @@ -311,12 +308,13 @@ proc main() = - if not os.fileExists("vk.xml"): + let file = getTempDir() / "vk.xml" + if not os.fileExists(file): let client = newHttpClient() let glUrl = "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs/main/xml/vk.xml" - client.downloadFile(glUrl, "vk.xml") + client.downloadFile(glUrl, file) - let api = loadXml("vk.xml") + let api = loadXml(file) const outdir = "src/vulkan_api/output" removeDir outdir @@ -352,6 +350,20 @@ "func VK_MAKE_API_VERSION*(variant: uint32, major: uint32, minor: uint32, patch: uint32): uint32 {.compileTime.} =", " (variant shl 29) or (major shl 22) or (minor shl 12) or patch", "", + """template checkVkResult*(call: untyped) = + when defined(release): + discard call + else: + # yes, a bit cheap, but this is only for nice debug output + var callstr = astToStr(call).replace("\n", "") + while callstr.find(" ") >= 0: + callstr = callstr.replace(" ", " ") + debug "CALLING vulkan: ", callstr + let value = call + if value != VK_SUCCESS: + error "Vulkan error: ", astToStr(call), " returned ", $value + raise newException(Exception, "Vulkan error: " & astToStr(call) & + " returned " & $value)""", "type", ], "structs": @["type"], @@ -505,7 +517,7 @@ for platform in api.findAll("platform"): mainout.add &"when defined({platform.attr(\"protect\")}):" mainout.add &" include platform/{platform.attr(\"name\")}" - writeFile outdir / &"types.nim", mainout.join("\n") + writeFile outdir / &"api.nim", mainout.join("\n") for filename, filecontent in outputFiles.pairs: if filename.startsWith("platform/"):