changeset 959:c104dbf5bbb8

did: adjust integer sizes to match vulkan API (more) directly
author sam <sam@basx.dev>
date Tue, 02 Apr 2024 16:09:38 +0700
parents 40214e384e2b
children 23c8072d7a53
files semicongine/algorithms.nim semicongine/core/dynamic_arrays.nim semicongine/core/gpu_types.nim semicongine/core/imagetypes.nim semicongine/mesh.nim semicongine/renderer.nim semicongine/resources/font.nim semicongine/resources/image.nim semicongine/resources/mesh.nim semicongine/vulkan/buffer.nim semicongine/vulkan/descriptor.nim semicongine/vulkan/drawable.nim semicongine/vulkan/image.nim semicongine/vulkan/pipeline.nim semicongine/vulkan/shader.nim
diffstat 15 files changed, 101 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/semicongine/algorithms.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/algorithms.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -4,30 +4,31 @@
 
 type
   Rect = tuple
-    i, x, y, w, h: int
+    i: int
+    x, y, w, h: uint32
 
-func between(a1, a2, b: int): bool =
+func between(a1, a2, b: uint32): bool =
   a1 <= b and b <= a2
 
-func overlap(a1, a2, b1, b2: int): bool =
+func overlap(a1, a2, b1, b2: uint32): bool =
   return between(a1, a2, b1) or
          between(a1, a2, b2) or
          between(b1, b2, a1) or
          between(b1, b2, a2)
 
 # FYI: also serves as "overlaps"
-func advanceIfOverlap(fix, newRect: Rect): (bool, int) =
+func advanceIfOverlap(fix, newRect: Rect): (bool, uint32) =
   let overlapping = overlap(fix.x, fix.x + fix.w - 1, newRect.x, newRect.x + newRect.w - 1) and
                     overlap(fix.y, fix.y + fix.h - 1, newRect.y, newRect.y + newRect.h - 1)
   if overlapping: (true, fix.x + fix.w) # next free x coordinate to the right
   else: (false, newRect.x) # current position is fine
 
-proc find_insertion_position(alreadyPlaced: seq[Rect], area: tuple[i, w, h: int], maxDim: int): (bool, Rect) =
-  var newRect = (i: area.i, x: 0, y: 0, w: area.w, h: area.h)
+proc find_insertion_position(alreadyPlaced: seq[Rect], area: tuple[i: int, w, h: uint32], maxDim: uint32): (bool, Rect) =
+  var newRect = (i: area.i, x: 0'u32, y: 0'u32, w: area.w, h: area.h)
 
   while newRect.y + newRect.h <= maxDim:
     var hasOverlap = false
-    var advanceX: int
+    var advanceX: uint32
 
     for placed in alreadyPlaced:
       (hasOverlap, advanceX) = placed.advanceIfOverlap(newRect)
@@ -45,16 +46,16 @@
   return (false, newRect)
 
 
-proc pack*[T: Pixel](images: seq[Image[T]]): tuple[atlas: Image[T], coords: seq[tuple[x: int, y: int]]] =
-  const MAX_ATLAS_SIZE = 4096
-  var areas: seq[tuple[i, w, h: int]]
+proc pack*[T: Pixel](images: seq[Image[T]]): tuple[atlas: Image[T], coords: seq[tuple[x: uint32, y: uint32]]] =
+  const MAX_ATLAS_SIZE = 4096'u32
+  var areas: seq[tuple[i: int, w, h: uint32]]
 
   for i in 0 ..< images.len:
     areas.add (i, images[i].width, images[i].height)
 
-  let areasBySize = areas.sortedByIt(-(it[1] * it[2]))
+  let areasBySize = areas.sortedByIt(-(it[1] * it[2]).int64)
   var assignedAreas: seq[Rect]
-  var maxDim = 128
+  var maxDim = 128'u32
 
   for area in areasBySize:
     var pos = find_insertion_position(assignedAreas, area, maxDim)
--- a/semicongine/core/dynamic_arrays.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/core/dynamic_arrays.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -56,8 +56,8 @@
     of Mat4F64: mat4f64: ref seq[TMat4[float64]]
     of TextureType: texture: ref seq[Texture]
 
-func size*(value: DataList): int =
-  value.theType.size * value.len
+func size*(value: DataList): uint64 =
+  value.theType.size * value.len.uint64
 
 func hash*(value: DataList): Hash =
   case value.theType
--- a/semicongine/core/gpu_types.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/core/gpu_types.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -57,7 +57,7 @@
   ShaderAttribute* = object
     name*: string
     theType*: DataType
-    arrayCount*: int
+    arrayCount*: uint32
     perInstance*: bool
     noInterpolation: bool
     memoryPerformanceHint*: MemoryPerformanceHint
@@ -81,14 +81,14 @@
     if attr.perInstance == false:
       result.add attr
 
-func numberOfVertexInputAttributeDescriptors*(theType: DataType): int =
+func numberOfVertexInputAttributeDescriptors*(theType: DataType): uint =
   case theType:
     of Mat2F32, Mat2F64, Mat23F32, Mat23F64: 2
     of Mat32F32, Mat32F64, Mat3F32, Mat3F64, Mat34F32, Mat34F64: 3
     of Mat43F32, Mat43F64, Mat4F32, Mat4F64: 4
     else: 1
 
-func size*(theType: DataType): int =
+func size*(theType: DataType): uint64 =
   case theType:
     of Float32: 4
     of Float64: 8
@@ -134,7 +134,7 @@
     of Mat4F64: 128
     of TextureType: 0
 
-func size*(attribute: ShaderAttribute, perDescriptor = false): int =
+func size*(attribute: ShaderAttribute, perDescriptor = false): uint64 =
   if perDescriptor:
     attribute.theType.size div attribute.theType.numberOfVertexInputAttributeDescriptors
   else:
@@ -143,7 +143,7 @@
     else:
       attribute.theType.size * attribute.arrayCount
 
-func size*(theType: seq[ShaderAttribute]): int =
+func size*(theType: seq[ShaderAttribute]): uint64 =
   for attribute in theType:
     result += attribute.size
 
@@ -204,7 +204,7 @@
 func attr*[T: GPUType](
   name: string,
   perInstance = false,
-  arrayCount = 0,
+  arrayCount = 0'u32,
   noInterpolation = false,
   memoryPerformanceHint = PreferFastRead,
 ): auto =
@@ -380,7 +380,7 @@
     return @[]
   # currently only a single uniform block supported, therefore binding = 0
   result.add(&"layout(std430, binding = {binding}) uniform T{blockName} {{")
-  var last_size = high(int)
+  var last_size = high(uint64)
   for attribute in group:
     assert attribute.size <= last_size, &"The attribute '{attribute.name}' is bigger than the attribute before, which is not allowed" # using smaller uniform-types first will lead to problems (I think due to alignment, there is also some stuff on the internet about this ;)
     var arrayDecl = ""
--- a/semicongine/core/imagetypes.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/core/imagetypes.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -8,8 +8,8 @@
   GrayPixel* = uint8
   Pixel* = RGBAPixel or GrayPixel
   ImageObject*[T: Pixel] = object
-    width*: int
-    height*: int
+    width*: uint32
+    height*: uint32
     imagedata*: seq[T]
   Image*[T: Pixel] = ref ImageObject[T]
 
@@ -47,25 +47,25 @@
   else:
     &"{texture.name} {texture.colorImage} (color)"
 
-proc `[]`*(image: Image, x, y: int): Pixel =
+proc `[]`*(image: Image, x, y: uint32): Pixel =
   assert x < image.width, &"{x} < {image.width} is not true"
   assert y < image.height, &"{y} < {image.height} is not true"
 
   image[].imagedata[y * image.width + x]
 
-proc `[]=`*(image: var Image, x, y: int, value: Pixel) =
+proc `[]=`*(image: var Image, x, y: uint32, value: Pixel) =
   assert x < image.width
   assert y < image.height
 
   image[].imagedata[y * image.width + x] = value
 
-proc newImage*[T: Pixel](width, height: int, imagedata: openArray[T] = []): Image[T] =
+proc newImage*[T: Pixel](width, height: uint32, imagedata: openArray[T] = []): Image[T] =
   assert width > 0 and height > 0
-  assert imagedata.len == width * height or imagedata.len == 0
+  assert imagedata.len.uint32 == width * height or imagedata.len == 0
 
   result = new Image[T]
   result.imagedata = (if imagedata.len == 0: newSeq[T](width * height) else: @imagedata)
-  assert width * height == result.imagedata.len
+  assert width * height == result.imagedata.len.uint32
 
   result.width = width
   result.height = height
--- a/semicongine/mesh.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/mesh.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -205,7 +205,7 @@
     name = name,
   )
 
-func attributeSize*(mesh: MeshObject, attribute: string): int =
+func attributeSize*(mesh: MeshObject, attribute: string): uint64 =
   if mesh.vertexData.contains(attribute):
     mesh.vertexData[attribute].size
   elif mesh.instanceData.contains(attribute):
@@ -221,17 +221,20 @@
   else:
     raise newException(Exception, &"Attribute {attribute} is not defined for mesh {mesh}")
 
-func indexSize*(mesh: MeshObject): int =
+func indexSize*(mesh: MeshObject): uint64 =
   case mesh.indexType
-    of None: 0
-    of Tiny: mesh.tinyIndices.len * sizeof(get(genericParams(typeof(mesh.tinyIndices)), 0))
-    of Small: mesh.smallIndices.len * sizeof(get(genericParams(typeof(mesh.smallIndices)), 0))
-    of Big: mesh.bigIndices.len * sizeof(get(genericParams(typeof(mesh.bigIndices)), 0))
+    of None: 0'u64
+    of Tiny: uint64(mesh.tinyIndices.len * sizeof(get(genericParams(typeof(mesh.tinyIndices)), 0)))
+    of Small: uint64(mesh.smallIndices.len * sizeof(get(genericParams(typeof(mesh.smallIndices)), 0)))
+    of Big: uint64(mesh.bigIndices.len * sizeof(get(genericParams(typeof(mesh.bigIndices)), 0)))
 
-func rawData[T: seq](value: T): (pointer, int) =
-  (pointer(addr(value[0])), sizeof(get(genericParams(typeof(value)), 0)) * value.len)
+func rawData[T: seq](value: T): (pointer, uint64) =
+  (
+    pointer(addr(value[0])),
+    uint64(sizeof(get(genericParams(typeof(value)), 0)) * value.len)
+  )
 
-func getRawIndexData*(mesh: MeshObject): (pointer, int) =
+func getRawIndexData*(mesh: MeshObject): (pointer, uint64) =
   case mesh.indexType:
     of None: raise newException(Exception, "Trying to get index data for non-indexed mesh")
     of Tiny: rawData(mesh.tinyIndices)
--- a/semicongine/renderer.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/renderer.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -32,7 +32,7 @@
     uniformBuffers*: Table[VkPipeline, seq[Buffer]]                 # one per frame-in-flight
     textures*: Table[VkPipeline, Table[string, seq[VulkanTexture]]] # per frame-in-flight
     attributeLocation*: Table[string, MemoryPerformanceHint]
-    vertexBufferOffsets*: Table[(Mesh, string), int]
+    vertexBufferOffsets*: Table[(Mesh, string), uint64]
     descriptorPools*: Table[VkPipeline, DescriptorPool]
     descriptorSets*: Table[VkPipeline, seq[DescriptorSet]]
     materials: Table[MaterialType, seq[MaterialData]]
@@ -170,14 +170,14 @@
   renderer.checkSceneIntegrity(scene)
 
   # create index buffer if necessary
-  var indicesBufferSize = 0
+  var indicesBufferSize = 0'u64
   for mesh in scene.meshes:
     if mesh[].indexType != MeshIndexType.None:
       let indexAlignment = case mesh[].indexType
-        of MeshIndexType.None: 0
-        of Tiny: 1
-        of Small: 2
-        of Big: 4
+        of MeshIndexType.None: 0'u64
+        of Tiny: 1'u64
+        of Small: 2'u64
+        of Big: 4'u64
       # index value alignment required by Vulkan
       if indicesBufferSize mod indexAlignment != 0:
         indicesBufferSize += indexAlignment - (indicesBufferSize mod indexAlignment)
@@ -192,7 +192,7 @@
 
   # calculcate offsets for attributes in vertex buffers
   # trying to use one buffer per memory type
-  var perLocationSizes: Table[MemoryPerformanceHint, int]
+  var perLocationSizes: Table[MemoryPerformanceHint, uint64]
   for hint in MemoryPerformanceHint:
     perLocationSizes[hint] = 0
 
@@ -219,8 +219,8 @@
       )
 
   # calculate offset of each attribute for all meshes
-  var perLocationOffsets: Table[MemoryPerformanceHint, int]
-  var indexBufferOffset = 0
+  var perLocationOffsets: Table[MemoryPerformanceHint, uint64]
+  var indexBufferOffset = 0'u64
   for hint in MemoryPerformanceHint:
     perLocationOffsets[hint] = 0
 
@@ -233,10 +233,10 @@
           perLocationOffsets[attribute.memoryPerformanceHint] += VERTEX_ATTRIB_ALIGNMENT - (perLocationOffsets[attribute.memoryPerformanceHint] mod VERTEX_ATTRIB_ALIGNMENT)
 
     # fill offsets per shaderPipeline (as sequence corresponds to shader input binding)
-    var offsets: Table[VkPipeline, seq[(string, MemoryPerformanceHint, int)]]
+    var offsets: Table[VkPipeline, seq[(string, MemoryPerformanceHint, uint64)]]
     for (materialType, shaderPipeline) in renderer.renderPass.shaderPipelines:
       if scene.usesMaterial(materialType):
-        offsets[shaderPipeline.vk] = newSeq[(string, MemoryPerformanceHint, int)]()
+        offsets[shaderPipeline.vk] = newSeq[(string, MemoryPerformanceHint, uint64)]()
         for attribute in shaderPipeline.inputs:
           offsets[shaderPipeline.vk].add (attribute.name, attribute.memoryPerformanceHint, scenedata.vertexBufferOffsets[(mesh, attribute.name)])
 
@@ -251,10 +251,10 @@
     )
     if indexed:
       let indexAlignment = case mesh.indexType
-        of MeshIndexType.None: 0
-        of Tiny: 1
-        of Small: 2
-        of Big: 4
+        of MeshIndexType.None: 0'u64
+        of Tiny: 1'u64
+        of Small: 2'u64
+        of Big: 4'u64
       # index value alignment required by Vulkan
       if indexBufferOffset mod indexAlignment != 0:
         indexBufferOffset += indexAlignment - (indexBufferOffset mod indexAlignment)
@@ -289,13 +289,13 @@
                 uploadedTextures[value[0]] = renderer.device.uploadTexture(renderer.queue, value[0])
               scenedata.textures[shaderPipeline.vk][texture.name].add uploadedTextures[value[0]]
           assert foundTexture, &"No texture found in shaderGlobals or materials for '{texture.name}'"
-        let nTextures = scenedata.textures[shaderPipeline.vk][texture.name].len
+        let nTextures = scenedata.textures[shaderPipeline.vk][texture.name].len.uint32
         assert (texture.arrayCount == 0 and nTextures == 1) or texture.arrayCount >= nTextures, &"Shader assigned to render '{materialType}' expected {texture.arrayCount} textures for '{texture.name}' but got {nTextures}"
         if texture.arrayCount < nTextures:
           warn &"Shader assigned to render '{materialType}' expected {texture.arrayCount} textures for '{texture.name}' but got {nTextures}"
 
       # gather uniform sizes
-      var uniformBufferSize = 0
+      var uniformBufferSize = 0'u64
       for uniform in shaderPipeline.uniforms:
         uniformBufferSize += uniform.size
       if uniformBufferSize > 0:
@@ -309,13 +309,13 @@
           )
 
       # TODO: rework the whole descriptor/pool/layout stuff, a bit unclear
-      var poolsizes = @[(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, renderer.swapchain.inFlightFrames)]
-      var nTextures = 0
+      var poolsizes = @[(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, renderer.swapchain.inFlightFrames.uint32)]
+      var nTextures = 0'u32
       for descriptor in shaderPipeline.descriptorSetLayout.descriptors:
         if descriptor.thetype == ImageSampler:
           nTextures += descriptor.count
       if nTextures > 0:
-        poolsizes.add (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, nTextures * renderer.swapchain.inFlightFrames)
+        poolsizes.add (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, nTextures * renderer.swapchain.inFlightFrames.uint32)
       scenedata.descriptorPools[shaderPipeline.vk] = renderer.device.createDescriptorSetPool(poolsizes)
 
       scenedata.descriptorSets[shaderPipeline.vk] = shaderPipeline.setupDescriptors(
@@ -393,7 +393,7 @@
         for buffer in renderer.scenedata[scene].uniformBuffers[shaderPipeline.vk]:
           assert buffer.vk.valid
 
-      var offset = 0
+      var offset = 0'u64
       # loop over all uniforms of the shader-shaderPipeline
       for uniform in shaderPipeline.uniforms:
         if dirty.contains(uniform.name) or dirtyMaterialAttribs.contains(uniform.name) or forceAll: # only update uniforms if necessary
@@ -408,8 +408,8 @@
                 value.appendValues(material[uniform.name])
                 foundValue = true
             assert foundValue, &"Uniform '{uniform.name}' not found in scene shaderGlobals or materials"
-          assert (uniform.arrayCount == 0 and value.len == 1) or value.len <= uniform.arrayCount, &"Uniform '{uniform.name}' found has wrong length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})"
-          if value.len <= uniform.arrayCount:
+          assert (uniform.arrayCount == 0 and value.len == 1) or value.len.uint <= uniform.arrayCount, &"Uniform '{uniform.name}' found has wrong length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})"
+          if value.len.uint <= uniform.arrayCount:
             debug &"Uniform '{uniform.name}' found has short length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})"
           assert value.size <= uniform.size, &"During uniform update: gathered value has size {value.size} but uniform expects size {uniform.size}"
           if value.size < uniform.size:
--- a/semicongine/resources/font.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/resources/font.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -81,7 +81,7 @@
       var bitmap = newSeq[GrayPixel](width * height)
       for i in 0 ..< width * height:
         bitmap[i] = GrayPixel(data[i])
-      images.add newImage[GrayPixel](int(width), int(height), bitmap)
+      images.add newImage[GrayPixel](width.uint32, height.uint32, bitmap)
     else:
       images.add empty_image
 
--- a/semicongine/resources/image.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/resources/image.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -104,7 +104,7 @@
       data[row_mult * dibHeader.width + col] = pixel
     stream.setPosition(stream.getPosition() + padding)
 
-  result = newImage(width = dibHeader.width, height = abs(dibHeader.height), imagedata = data)
+  result = newImage(width = dibHeader.width.uint32, height = abs(dibHeader.height).uint32, imagedata = data)
 
 {.compile: currentSourcePath.parentDir() & "/lodepng.c".}
 
@@ -127,7 +127,7 @@
 
   free(data)
 
-  result = newImage(width = int(w), height = int(h), imagedata = imagedata)
+  result = newImage(width = w, height = h, imagedata = imagedata)
 
 proc toPNG*[T: Pixel](image: Image[T]): seq[uint8] =
   when T is GrayPixel:
--- a/semicongine/resources/mesh.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/resources/mesh.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -123,7 +123,7 @@
     # we don't support stride, have to convert stuff here... does this even work?
     for i in 0 ..< int(result.len):
       copyMem(dstPointer, addr mainBuffer[bufferOffset + i * bufferView["byteStride"].getInt()], int(result.thetype.size))
-      dstPointer = cast[pointer](cast[int](dstPointer) + result.thetype.size)
+      dstPointer = cast[pointer](cast[uint](dstPointer) + result.thetype.size)
   else:
     copyMem(dstPointer, addr mainBuffer[bufferOffset], length)
 
--- a/semicongine/vulkan/buffer.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/vulkan/buffer.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -14,7 +14,7 @@
   Buffer* = object
     device*: Device
     vk*: VkBuffer
-    size*: int
+    size*: uint64
     usage*: seq[VkBufferUsageFlagBits]
     case memoryAllocated*: bool
       of false: discard
@@ -67,7 +67,7 @@
 # (shardingMode = VK_SHARING_MODE_CONCURRENT not supported)
 proc createBuffer*(
   device: Device,
-  size: int,
+  size: uint64,
   usage: openArray[VkBufferUsageFlagBits],
   requireMappable: bool,
   preferVRAM: bool,
@@ -84,7 +84,7 @@
   var createInfo = VkBufferCreateInfo(
     sType: VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
     flags: VkBufferCreateFlags(0),
-    size: uint64(size),
+    size: size,
     usage: toBits(result.usage),
     sharingMode: VK_SHARING_MODE_EXCLUSIVE,
   )
@@ -98,11 +98,11 @@
   result.allocateMemory(requireMappable = requireMappable, preferVRAM = preferVRAM, preferAutoFlush = preferAutoFlush)
 
 
-proc copy*(src, dst: Buffer, queue: Queue, dstOffset = 0) =
+proc copy*(src, dst: Buffer, queue: Queue, dstOffset = 0'u64) =
   assert src.device.vk.valid
   assert dst.device.vk.valid
   assert src.device == dst.device
-  assert src.size <= dst.size - dstOffset
+  assert src.size + dstOffset <= dst.size
   assert VK_BUFFER_USAGE_TRANSFER_SRC_BIT in src.usage
   assert VK_BUFFER_USAGE_TRANSFER_DST_BIT in dst.usage
 
@@ -129,10 +129,10 @@
 template canMap*(buffer: Buffer): bool =
   buffer.memory.canMap
 
-proc setData*(dst: Buffer, queue: Queue, src: pointer, size: int, bufferOffset = 0) =
+proc setData*(dst: Buffer, queue: Queue, src: pointer, size: uint64, bufferOffset = 0'u64) =
   assert bufferOffset + size <= dst.size
   if dst.canMap:
-    copyMem(cast[pointer](cast[int](dst.memory.data) + bufferOffset), src, size)
+    copyMem(cast[pointer](cast[uint](dst.memory.data) + bufferOffset), src, size)
     if dst.memory.needsFlushing:
       dst.memory.flush()
   else: # use staging buffer, slower but required if memory is not host visible
--- a/semicongine/vulkan/descriptor.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/vulkan/descriptor.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -11,13 +11,13 @@
     Uniform, ImageSampler
   Descriptor* = object # "fields" of a DescriptorSetLayout
     name*: string
-    count*: int
+    count*: uint32
     stages*: seq[VkShaderStageFlagBits]
     case thetype*: DescriptorType
     of Uniform:
       buffer*: Buffer
-      offset*: int
-      size*: int
+      offset*: uint64
+      size*: uint64
     of ImageSampler:
       imageviews*: seq[ImageView]
       samplers*: seq[VulkanSampler]
@@ -28,11 +28,11 @@
     device: Device
     vk*: VkDescriptorSetLayout
     descriptors*: seq[Descriptor]
-  DescriptorPool* = object                # required for allocation of DescriptorSet
+  DescriptorPool* = object                   # required for allocation of DescriptorSet
     device: Device
     vk*: VkDescriptorPool
-    maxSets*: int                         # maximum number of allocatable descriptor sets
-    counts*: seq[(VkDescriptorType, int)] # maximum number for each descriptor type to allocate
+    maxSets*: int                            # maximum number of allocatable descriptor sets
+    counts*: seq[(VkDescriptorType, uint32)] # maximum number for each descriptor type to allocate
 
 const DESCRIPTOR_TYPE_MAP = {
   Uniform: VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
@@ -53,7 +53,7 @@
     layoutbindings.add VkDescriptorSetLayoutBinding(
       binding: uint32(i),
       descriptorType: descriptor.vkType,
-      descriptorCount: uint32(descriptor.count),
+      descriptorCount: descriptor.count,
       stageFlags: toBits descriptor.stages,
       pImmutableSamplers: nil,
     )
@@ -71,7 +71,7 @@
   descriptorSetLayout.vk.reset
 
 
-proc createDescriptorSetPool*(device: Device, counts: seq[(VkDescriptorType, int)], maxSets = 1000): DescriptorPool =
+proc createDescriptorSetPool*(device: Device, counts: seq[(VkDescriptorType, uint32)], maxSets = 1000): DescriptorPool =
   assert device.vk.valid
 
   result.device = device
@@ -80,7 +80,7 @@
 
   var poolSizes: seq[VkDescriptorPoolSize]
   for (thetype, count) in result.counts:
-    poolSizes.add VkDescriptorPoolSize(thetype: thetype, descriptorCount: uint32(count))
+    poolSizes.add VkDescriptorPoolSize(thetype: thetype, descriptorCount: count)
   var poolInfo = VkDescriptorPoolCreateInfo(
     sType: VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
     poolSizeCount: uint32(poolSizes.len),
@@ -139,8 +139,8 @@
       assert descriptor.buffer.vk.valid
       bufferInfos.add VkDescriptorBufferInfo(
         buffer: descriptor.buffer.vk,
-        offset: uint64(descriptor.offset),
-        range: uint64(descriptor.size),
+        offset: descriptor.offset,
+        range: descriptor.size,
       )
       descriptorSetWrites.add VkWriteDescriptorSet(
           sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
--- a/semicongine/vulkan/drawable.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/vulkan/drawable.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -8,13 +8,13 @@
 type
   Drawable* = object
     name*: string
-    elementCount*: int                                                           # number of vertices or indices
-    bufferOffsets*: Table[VkPipeline, seq[(string, MemoryPerformanceHint, int)]] # list of buffers and list of offset for each attribute in that buffer
-    instanceCount*: int                                                          # number of instance
+    elementCount*: int                                                              # number of vertices or indices
+    bufferOffsets*: Table[VkPipeline, seq[(string, MemoryPerformanceHint, uint64)]] # list of buffers and list of offset for each attribute in that buffer
+    instanceCount*: int                                                             # number of instance
     case indexed*: bool
     of true:
       indexType*: VkIndexType
-      indexBufferOffset*: int
+      indexBufferOffset*: uint64
     of false:
       discard
 
--- a/semicongine/vulkan/image.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/vulkan/image.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -14,8 +14,8 @@
   VulkanImage* = object
     device*: Device
     vk*: VkImage
-    width*: int  # pixel
-    height*: int # pixel
+    width*: uint32  # pixel
+    height*: uint32 # pixel
     depth*: PixelDepth
     format*: VkFormat
     usage*: seq[VkImageUsageFlagBits]
@@ -131,7 +131,7 @@
       layerCount: 1,
     ),
     imageOffset: VkOffset3D(x: 0, y: 0, z: 0),
-    imageExtent: VkExtent3D(width: uint32(dst.width), height: uint32(dst.height), depth: 1)
+    imageExtent: VkExtent3D(width: dst.width, height: dst.height, depth: 1)
   )
   withSingleUseCommandBuffer(src.device, queue, commandBuffer):
     commandBuffer.vkCmdCopyBufferToImage(
@@ -143,14 +143,14 @@
     )
 
 # currently only usable for texture access from shader
-proc createImage(device: Device, queue: Queue, width, height: int, depth: PixelDepth, data: pointer): VulkanImage =
+proc createImage(device: Device, queue: Queue, width, height: uint32, depth: PixelDepth, data: pointer): VulkanImage =
   assert device.vk.valid
   assert width > 0
   assert height > 0
   assert depth != 2
   assert data != nil
 
-  let size = width * height * depth
+  let size: uint64 = width * height * uint32(depth)
   result.device = device
   result.width = width
   result.height = height
@@ -170,9 +170,11 @@
     addr formatInfo,
     addr formatProperties,
   )
-  assert size <= int(formatProperties.imageFormatProperties.maxResourceSize)
-  assert width <= int(formatProperties.imageFormatProperties.maxExtent.width)
-  assert height <= int(formatProperties.imageFormatProperties.maxExtent.height)
+  assert size <= uint64(formatProperties.imageFormatProperties.maxResourceSize)
+  assert width <= uint64(formatProperties.imageFormatProperties.maxExtent.width)
+  assert height <= uint64(formatProperties.imageFormatProperties.maxExtent.height)
+
+  echo formatProperties
 
   var imageInfo = VkImageCreateInfo(
     sType: VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
--- a/semicongine/vulkan/pipeline.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/vulkan/pipeline.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -34,7 +34,7 @@
   result = descriptorPool.allocateDescriptorSet(pipeline.descriptorSetLayout, inFlightFrames)
 
   for i in 0 ..< inFlightFrames:
-    var offset = 0
+    var offset = 0'u64
     # first descriptor is always uniform for globals, match should be better somehow
     for descriptor in result[i].layout.descriptors.mitems:
       if descriptor.thetype == Uniform and buffers.len > 0:
--- a/semicongine/vulkan/shader.nim	Tue Apr 02 14:05:22 2024 +0700
+++ b/semicongine/vulkan/shader.nim	Tue Apr 02 16:09:38 2024 +0700
@@ -5,7 +5,6 @@
 import std/hashes
 import std/strformat
 import std/strutils
-import std/compilesettings
 
 import ../core
 import ./device