Hello again
having trouble with any of the tables, i'm not sure how they work it seems, and the manual is kinda skimpy too.
so here is my code
proc sort_queue_properties(index:int): Table[uint32,string] =
var queue_table = Table[uint32,string]()
for i in 0 .. <queue_properties[index].queueCount:
if (queue_properties[index].queueFlags and vkQueueGraphicsBit) == 1:
queue_table = {i:"vkQueueGraphicsBit"}.toTable
if (queue_properties[index].queueFlags and vkQueueComputeBit) == 1:
queue_table.add(i,"vkQueueComputeBit")
if (queue_properties[index].queueFlags and vkQueueTransferBit) == 1:
queue_table.add(i,"vkQueueTransferBit")
if (queue_properties[index].queueFlags and vkQueueSparseBindingBit) == 1:
queue_table.add(i,"vkQueueSparseBindingBit")
return queue_table
proc get_queue_properties*() =
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,addr queue_count,nil)
queue_properties.setLen(queue_count);
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,addr queue_count,addr queue_properties[0])
for t in 0 .. <queue_properties.len:
let table = sort_queue_properties(t)
for i in 0 .. table.len:
echo table[i]
i end up with no values in my table even though i know the first if statement works.
and so i print out nothing of course.
anyway some example would be nice.
edit: posted queue_properties
Your code is missing queue_properties implementation/instantiation. Please post a snippet that compile or edit your post.
also this won't compile
var queue_table = Table[uint32,string]()
bu this will
var queue_table = initTable[uint32,string]()
Interesting enough
var queue_table = Table[uint32,string]()
actually compiles on my machine.
i'm using mingw64-6.3 from this website and x64 nim_0.17.0 too it maybe why i am confused.
i haven't used tables before, i don't know what the correct syntax is.
correction: it will compile but table fields won't be initialized properly. use:
initTable[T, U](initial_size) #initial_size must be pow of 2
or if you want a ref value
newTable[T, U](initial_size) #initial_size must be pow of 2
still having problems, it seems that the table loses its info on length and value when i return it?
for instance
proc sort_queue_properties(index:int): TableRef[uint32,string] =
var queue_table = newTable[uint32,string](queue_properties[index].queueCount.int)
for i in 0 .. <queue_properties[index].queueCount:
echo queue_table.len
if (queue_properties[index].queueFlags and vkQueueGraphicsBit) == 1:
queue_table.add(i,"vkQueueGraphicsBit")
if (queue_properties[index].queueFlags and vkQueueComputeBit) == 1:
queue_table.add(i,"vkQueueComputeBit")
if (queue_properties[index].queueFlags and vkQueueTransferBit) == 1:
queue_table.add(i,"vkQueueTransferBit")
if (queue_properties[index].queueFlags and vkQueueSparseBindingBit) == 1:
queue_table.add(i,"vkQueueSparseBindingBit")
return queue_table
proc get_queue_properties*() =
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,addr queue_count,nil)
queue_properties.setLen(queue_count);
vkGetPhysicalDeviceQueueFamilyProperties(physical_device,addr queue_count,addr queue_properties[0])
for t in 0 .. <queue_properties.len:
let table = sort_queue_properties(t)
echo table.len
on this code the return of sort_queue_properties(t) returns a 0 value when i echo it, but the echo on queue_table length print out 0 to 15 like it should.
For that behaviour we may have a simple reason:
In your proc sort_queue_properties() you ONLY return your var queue_table when the last if condition is true. Otherwise the default result variable is returned, which has len 0 of course.
stefan your right that was it, thank you. I'm pretty sure i got it fixed with this code. I realized i needed a continue in the if statements too.
proc sort_queue_properties(index:int): TableRef[uint32,string] =
result = newTable[uint32,string](queue_properties[index].queueCount.int)
for i in 0 .. <queue_properties[index].queueCount:
if (queue_properties[index].queueFlags and vkQueueGraphicsBit) == 1:
result.add(i,"vkQueueGraphicsBit")
continue
if (queue_properties[index].queueFlags and vkQueueComputeBit) == 1:
result.add(i,"vkQueueComputeBit")
continue
if (queue_properties[index].queueFlags and vkQueueTransferBit) == 1:
result.add(i,"vkQueueTransferBit")
continue
if (queue_properties[index].queueFlags and vkQueueSparseBindingBit) == 1:
result.add(i,"vkQueueSparseBindingBit")
continue
else:
result.add(i,nil)
i will come back to this code later to fix the if statements for other queueFlags