# HG changeset patch # User sam # Date 1712392029 -25200 # Node ID ac3025fcc3244f2f074d6ec91b8b92682e025a13 # Parent c5655f79070dc00da831b165185c48ccda30bf32 fix: tests diff -r c5655f79070d -r ac3025fcc324 config.nims --- a/config.nims Fri Apr 05 23:19:45 2024 +0700 +++ b/config.nims Sat Apr 06 15:27:09 2024 +0700 @@ -12,7 +12,19 @@ semicongine_build_switches(buildname = "dev") setCommand "c" let outdir = semicongine_builddir(buildname = "dev") - semicongine_pack(outdir, bundleType = "exe", resourceRoot = "resources") + semicongine_pack(outdir, bundleType = "exe", resourceRoot = "tests/resources", withSteam = false) + +task build_dev_zip, "build dev zip": + semicongine_build_switches(buildname = "dev") + setCommand "c" + let outdir = semicongine_builddir(buildname = "dev") + semicongine_pack(outdir, bundleType = "zip", resourceRoot = "tests/resources", withSteam = false) + +task build_dev_dir, "build dev dir": + semicongine_build_switches(buildname = "dev") + setCommand "c" + let outdir = semicongine_builddir(buildname = "dev") + semicongine_pack(outdir, bundleType = "dir", resourceRoot = "tests/resources", withSteam = false) task build_release, "build release": switch "define", "release" @@ -20,7 +32,7 @@ semicongine_build_switches(buildname = "release") setCommand "c" let outdir = semicongine_builddir(buildname = "release") - semicongine_pack(outdir, bundleType = "exe", resourceRoot = "resources") + semicongine_pack(outdir, bundleType = "exe", resourceRoot = "tests/resources", withSteam = false) task build_all_debug, "build all examples for debug": @@ -36,11 +48,11 @@ task test_all, "Run all test programs": for file in listFiles("tests"): if file.endsWith(".nim") and not file.endsWith("test_resources.nim"): - exec(&"nim build --run {file}") + exec(&"nim build_dev --run {file}") - exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=dir --run tests/test_resources.nim") - exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=zip --run tests/test_resources.nim") - exec("nim build -d:BUILD_RESOURCEROOT=tests/resources -d:PACKAGETYPE=exe --run tests/test_resources.nim") + exec("nim build_dev --run tests/test_resources.nim") + exec("nim build_dev_zip --run tests/test_resources.nim") + exec("nim build_dev_dir --run tests/test_resources.nim") task publish, "publish all build": for file in listDirs("build/debug/linux"): diff -r c5655f79070d -r ac3025fcc324 semicongine.nimble --- a/semicongine.nimble Fri Apr 05 23:19:45 2024 +0700 +++ b/semicongine.nimble Sat Apr 06 15:27:09 2024 +0700 @@ -6,14 +6,13 @@ description = "Game engine, for games that run on semiconductor engines" license = "MIT" backend = "c" -installDirs = @["semicongine"] -# Dependencies -# On linux/debian also run the following to get everything working -# sudo dpkg --add-architecture i386 -# sudo apt-get update -# sudo apt-get install zip unzip libstdc++6:i386 libc6:i386 - +if detectOS(Linux): + foreignDep "zip" + foreignDep "unzip" + # required for builds using steam + foreignDep "libstdc++6:i386" + foreignDep "libc6:i386" requires "nim >= 2.0" requires "winim" diff -r c5655f79070d -r ac3025fcc324 semicongine/build.nim --- a/semicongine/build.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/semicongine/build.nim Sat Apr 06 15:27:09 2024 +0700 @@ -49,6 +49,8 @@ proc semicongine_pack*(outdir: string, bundleType: string, resourceRoot: string, withSteam: bool) = switch("define", "PACKAGETYPE=" & bundleType) + assert resourceRoot.dirExists, &"Resource root '{resourceRoot}' does not exists" + outdir.rmDir() outdir.mkDir() @@ -58,13 +60,15 @@ cpDir(resourceRoot, outdir_resources) elif bundleType == "zip": outdir_resources.mkDir() - for resource in listDirs(resourceRoot): - let outputfile = joinPath(outdir_resources, resource.splitPath().tail & ".zip") - withdir resource: + for resourceDir in resourceRoot.listDirs(): + let outputfile = joinPath(outdir_resources, resourceDir.splitPath().tail & ".zip") + withdir resourceDir: if defined(linux): - exec &"zip -r {outputfile} ." + echo &"zip -r {relativePath(outputfile, resourceDir)} ." + exec &"zip -r {relativePath(outputfile, resourceDir)} ." elif defined(windows): - exec &"powershell Compress-Archive * {outputfile}" + echo &"powershell Compress-Archive * {relativePath(outputfile, resourceDir)}" + exec &"powershell Compress-Archive * {relativePath(outputfile, resourceDir)}" else: raise newException(Exception, "Unsupported platform") elif bundleType == "exe": diff -r c5655f79070d -r ac3025fcc324 semicongine/vulkan/device.nim --- a/semicongine/vulkan/device.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/semicongine/vulkan/device.nim Sat Apr 06 15:27:09 2024 +0700 @@ -32,7 +32,7 @@ assert queueFamilies.len > 0 result.physicalDevice = physicalDevice - var allExtensions = enabledExtensions & @["VK_KHR_swapchain"] + var allExtensions = enabledExtensions & @["VK_KHR_swapchain", "VK_KHR_uniform_buffer_standard_layout"] for extension in allExtensions: instance.vk.loadExtension(extension) var @@ -48,9 +48,14 @@ ) var queueList = deviceQueues.values.toSeq + var uniformBufferLayoutFeature = VkPhysicalDeviceUniformBufferStandardLayoutFeatures( + stype: VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, + uniformBufferStandardLayout: true, + ) var features2 = VkPhysicalDeviceFeatures2( stype: VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, features: result.enabledFeatures, + pnext: addr uniformBufferLayoutFeature, ) var createInfo = VkDeviceCreateInfo( sType: VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, diff -r c5655f79070d -r ac3025fcc324 semicongine/vulkan/image.nim --- a/semicongine/vulkan/image.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/semicongine/vulkan/image.nim Sat Apr 06 15:27:09 2024 +0700 @@ -187,10 +187,11 @@ checkVkResult formatCheck # assumption: images comes in sRGB color space + # convert to linear space if there is not support for sRGB var data = addr image.imagedata[0] if selectedFormat in LINEAR_FORMATS: let linearImage = image.asLinear() - data = addr image.imagedata[0] + data = addr linearImage.imagedata[0] assert size <= uint64(formatProperties.imageFormatProperties.maxResourceSize) assert width <= uint64(formatProperties.imageFormatProperties.maxExtent.width) diff -r c5655f79070d -r ac3025fcc324 tests/test_font.nim --- a/tests/test_font.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/tests/test_font.nim Sat Apr 06 15:27:09 2024 +0700 @@ -12,7 +12,7 @@ # build scene var scene = Scene(name: "main") var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32) - var origin = initPanel(size = newVec2f(0.01, 0.01)) + var origin = initPanel(transform = scale(0.01, 0.01)) var main_text = font.initText("".toRunes, maxLen = 255, color = newVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = scale(0.0005, 0.0005)) var help_text = font.initText("""Controls diff -r c5655f79070d -r ac3025fcc324 tests/test_materials.nim --- a/tests/test_materials.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/tests/test_materials.nim Sat Apr 06 15:27:09 2024 +0700 @@ -50,8 +50,8 @@ ], uniforms = [attr[float32]("test2", arrayCount = 2)], samplers = @[ - attr[Texture]("tex1", arrayCount = 1), - attr[Texture]("tex2", arrayCount = 1), + attr[Texture]("tex1"), + attr[Texture]("tex2"), ], outputs = [attr[Vec4f]("color")], vertexCode = """ @@ -59,7 +59,7 @@ uvout = uv;""", fragmentCode = """ float d = sin(Uniforms.test2[0]) * 0.5 + 0.5; - color = texture(tex1[0], uvout) * (1 - d) + texture(tex2[0], uvout) * d; + color = texture(tex1, uvout) * (1 - d) + texture(tex2, uvout) * d; """, ) engine.initRenderer({ diff -r c5655f79070d -r ac3025fcc324 tests/test_mesh.nim --- a/tests/test_mesh.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/tests/test_mesh.nim Sat Apr 06 15:27:09 2024 +0700 @@ -1,3 +1,4 @@ +import std/strformat import semicongine proc main() = diff -r c5655f79070d -r ac3025fcc324 tests/test_vulkan_wrapper.nim --- a/tests/test_vulkan_wrapper.nim Fri Apr 05 23:19:45 2024 +0700 +++ b/tests/test_vulkan_wrapper.nim Sat Apr 06 15:27:09 2024 +0700 @@ -233,8 +233,6 @@ engine.destroy() return engine.renderScene(scene) - echo "Rendered ", engine.framesRendered, " frames" - echo "Processed ", engine.eventsProcessed, " events" # cleanup echo "Start cleanup"