# HG changeset patch # User Sam # Date 1677260645 -25200 # Node ID 8bfcaed87cd62ece07042e7e9bbb4e7b53af7435 # Parent 8412f433dc4644d56bd6780a900810c0a7eb443a did: a few fixes for new API diff -r 8412f433dc46 -r 8bfcaed87cd6 examples/E10_pong.nim --- a/examples/E10_pong.nim Fri Feb 24 01:32:45 2023 +0700 +++ b/examples/E10_pong.nim Sat Feb 25 00:44:05 2023 +0700 @@ -18,6 +18,8 @@ backgroundColor = RGBAfromHex("FAC034").gamma(2.2) ballSpeed = 60'f +echo RGBAfromHex("FAC034") +echo RGBAfromHex("FAC034").gamma(2.2) var uniforms = Uniforms() pipeline: RenderPipeline[Vertex, Uniforms] diff -r 8412f433dc46 -r 8bfcaed87cd6 src/semicongine/color.nim --- a/src/semicongine/color.nim Fri Feb 24 01:32:45 2023 +0700 +++ b/src/semicongine/color.nim Sat Feb 25 00:44:05 2023 +0700 @@ -12,9 +12,9 @@ hex = hex[0] & hex[0] & hex[1] & hex[1] & hex[2] & hex[2] var r, g, b: uint8 assert hex.len == 6 - assert parseHex(hex[0 .. 1], r) == 2 - assert parseHex(hex[2 .. 3], g) == 2 - assert parseHex(hex[4 .. 5], b) == 2 + discard parseHex(hex[0 .. 1], r) == 2 + discard parseHex(hex[2 .. 3], g) == 2 + discard parseHex(hex[4 .. 5], b) == 2 return Vec3([float32(r), float32(g), float32(b)]) / 255'f func RGBAfromHex*(value: string): Vec4 = @@ -32,10 +32,10 @@ hex = hex & "ff" assert hex.len == 8 var r, g, b, a: uint8 - assert parseHex(hex[0 .. 1], r) == 2 - assert parseHex(hex[2 .. 3], g) == 2 - assert parseHex(hex[4 .. 5], b) == 2 - assert parseHex(hex[6 .. 7], a) == 2 + discard parseHex(hex[0 .. 1], r) + discard parseHex(hex[2 .. 3], g) + discard parseHex(hex[4 .. 5], b) + discard parseHex(hex[6 .. 7], a) return Vec4([float32(r), float32(g), float32(b), float32(a)]) / 255'f func gamma*[T: Vec3|Vec4](color: T, gamma: float32): auto = diff -r 8412f433dc46 -r 8bfcaed87cd6 src/semicongine/engine.nim --- a/src/semicongine/engine.nim Fri Feb 24 01:32:45 2023 +0700 +++ b/src/semicongine/engine.nim Sat Feb 25 00:44:05 2023 +0700 @@ -643,8 +643,7 @@ dstArrayElement: 0, descriptorType: VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, descriptorCount: 1, - pBufferInfo: cast[ptr ptr VkDescriptorBufferInfo](addr(bufferInfos[i][ - 0])), + pBufferInfo: addr(bufferInfos[i][0]), ) vkUpdateDescriptorSets(result.device, 1, addr(descriptorWrite), 0, nil) diff -r 8412f433dc46 -r 8bfcaed87cd6 src/semicongine/vulkan/api.nim --- a/src/semicongine/vulkan/api.nim Fri Feb 24 01:32:45 2023 +0700 +++ b/src/semicongine/vulkan/api.nim Sat Feb 25 00:44:05 2023 +0700 @@ -11626,4 +11626,4 @@ converter VkBool2NimBool*(a: VkBool32): bool = a > 0 converter NimBool2VkBool*(a: bool): VkBool32 = VkBool32(a) -proc `$`*(x: uint32): string {.raises: [].} = addInt(result, x) \ No newline at end of file +proc `$`*(x: uint32): string {.raises: [].} = addInt(result, x) diff -r 8412f433dc46 -r 8bfcaed87cd6 src/semicongine/vulkan_helpers.nim --- a/src/semicongine/vulkan_helpers.nim Fri Feb 24 01:32:45 2023 +0700 +++ b/src/semicongine/vulkan_helpers.nim Sat Feb 25 00:44:05 2023 +0700 @@ -144,8 +144,7 @@ var usableLayers = newSeq[cstring]() when ENABLEVULKANVALIDATIONLAYERS: - const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, - "VK_LAYER_MESA_overlay".cstring] + const desiredLayers = ["VK_LAYER_KHRONOS_validation".cstring, "VK_LAYER_MESA_overlay".cstring] else: const desiredLayers: array[0, string] = [] for layer in desiredLayers: @@ -155,7 +154,7 @@ echo "Available validation layers: ", availableLayers echo "Using validation layers: ", usableLayers echo "Available extensions: ", availableExtensions - echo "Using extensions: ", requiredExtensions + echo "Using instance extensions: ", requiredExtensions var appinfo = VkApplicationInfo( sType: VK_STRUCTURE_TYPE_APPLICATION_INFO, @@ -174,14 +173,10 @@ requiredExtensions[0])) ) checkVkResult vkCreateInstance(addr(createinfo), nil, addr(result)) - for extension in requiredExtensions: + let other_extensions = @["VK_KHR_swapchain".cstring] + for extension in requiredExtensions & other_extensions: result.loadExtension($extension) - # loadVK_KHR_surface(result) - # loadVK_KHR_swapchain(result) - when ENABLEVULKANVALIDATIONLAYERS: - loadVK_EXT_debug_utils(result) - proc getVulcanDevice*( physicalDevice: var VkPhysicalDevice,