@@ -12,11 +12,11 @@ open System.Threading
12
12
type CopyCommand =
13
13
internal
14
14
| BufferToBufferCmd of src : VkBuffer * dst : VkBuffer * info : VkBufferCopy
15
- | BufferToImageCmd of src : VkBuffer * dst : VkImage * dstLayout : VkImageLayout * info : VkBufferImageCopy * size : int64
16
- | ImageToBufferCmd of src : VkImage * srcLayout : VkImageLayout * dst : VkBuffer * info : VkBufferImageCopy * size : int64
17
- | ImageToImageCmd of src : VkImage * srcLayout : VkImageLayout * dst : VkImage * dstLayout : VkImageLayout * info : VkImageCopy * size : int64
15
+ | BufferToImageCmd of src : VkBuffer * dst : VkImage * dstLayout : VkImageLayout * info : VkBufferImageCopy * size : uint64
16
+ | ImageToBufferCmd of src : VkImage * srcLayout : VkImageLayout * dst : VkBuffer * info : VkBufferImageCopy * size : uint64
17
+ | ImageToImageCmd of src : VkImage * srcLayout : VkImageLayout * dst : VkImage * dstLayout : VkImageLayout * info : VkImageCopy * size : uint64
18
18
| CallbackCmd of ( unit -> unit )
19
- | ReleaseBufferCmd of buffer : VkBuffer * offset : int64 * size : int64 * dstQueueFamily : uint32
19
+ | ReleaseBufferCmd of buffer : VkBuffer * offset : uint64 * size : uint64 * dstQueueFamily : uint32
20
20
| ReleaseImageCmd of image : VkImage * range : VkImageSubresourceRange * srcLayout : VkImageLayout * dstLayout : VkImageLayout * dstQueueFamily : uint32
21
21
| TransformLayoutCmd of image : VkImage * range : VkImageSubresourceRange * srcLayout : VkImageLayout * dstLayout : VkImageLayout
22
22
@@ -26,19 +26,19 @@ type CopyCommand =
26
26
static member SyncImage ( image : VkImage , range : VkImageSubresourceRange , layout : VkImageLayout ) =
27
27
CopyCommand.TransformLayoutCmd( image, range, layout, layout)
28
28
29
- static member Copy ( src : VkBuffer , srcOffset : int64 , dst : VkBuffer , dstOffset : int64 , size : int64 ) =
29
+ static member Copy ( src : VkBuffer , srcOffset : uint64 , dst : VkBuffer , dstOffset : uint64 , size : uint64 ) =
30
30
CopyCommand.BufferToBufferCmd(
31
31
src,
32
32
dst,
33
- VkBufferCopy( uint64 srcOffset, uint64 dstOffset, uint64 size)
33
+ VkBufferCopy( srcOffset, dstOffset, size)
34
34
)
35
35
36
36
static member Copy ( src : VkBuffer , dst : VkImage , dstLayout : VkImageLayout , format : VkFormat , info : VkBufferImageCopy ) =
37
37
let sizeInBytes =
38
- int64 info.imageExtent.width *
39
- int64 info.imageExtent.height *
40
- int64 info.imageExtent.depth *
41
- int64 ( VkFormat.sizeInBytes format)
38
+ uint64 info.imageExtent.width *
39
+ uint64 info.imageExtent.height *
40
+ uint64 info.imageExtent.depth *
41
+ uint64 ( VkFormat.sizeInBytes format)
42
42
43
43
CopyCommand.BufferToImageCmd(
44
44
src,
@@ -48,10 +48,10 @@ type CopyCommand =
48
48
49
49
static member Copy ( src : VkImage , srcLayout : VkImageLayout , dst : VkBuffer , format : VkFormat , info : VkBufferImageCopy ) =
50
50
let sizeInBytes =
51
- int64 info.imageExtent.width *
52
- int64 info.imageExtent.height *
53
- int64 info.imageExtent.depth *
54
- int64 ( VkFormat.sizeInBytes format)
51
+ uint64 info.imageExtent.width *
52
+ uint64 info.imageExtent.height *
53
+ uint64 info.imageExtent.depth *
54
+ uint64 ( VkFormat.sizeInBytes format)
55
55
56
56
CopyCommand.ImageToBufferCmd(
57
57
src, srcLayout,
@@ -62,18 +62,18 @@ type CopyCommand =
62
62
static member Callback ( cb : unit -> unit ) =
63
63
CopyCommand.CallbackCmd cb
64
64
65
- static member Release ( buffer : VkBuffer , offset : int64 , size : int64 , dstQueueFamily : int ) =
65
+ static member Release ( buffer : VkBuffer , offset : uint64 , size : uint64 , dstQueueFamily : int ) =
66
66
CopyCommand.ReleaseBufferCmd( buffer, offset, size, uint32 dstQueueFamily)
67
67
68
68
static member Release ( image : VkImage , range : VkImageSubresourceRange , srcLayout : VkImageLayout , dstLayout : VkImageLayout , dstQueueFamily : int ) =
69
69
CopyCommand.ReleaseImageCmd( image, range, srcLayout, dstLayout, uint32 dstQueueFamily)
70
70
71
71
member x.SizeInBytes =
72
72
match x with
73
- | BufferToBufferCmd(_,_, i) -> int64 i.size
73
+ | BufferToBufferCmd(_,_, i) -> i.size
74
74
| BufferToImageCmd(_,_,_,_, s) -> s
75
75
| ImageToBufferCmd(_,_,_,_, s) -> s
76
- | _ -> 0 L
76
+ | _ -> 0 UL
77
77
78
78
and CopyEngine ( family : DeviceQueueFamily ) =
79
79
let familyIndex = family.Index
@@ -83,7 +83,7 @@ and CopyEngine(family: DeviceQueueFamily) =
83
83
// queue
84
84
let lockObj = obj()
85
85
let mutable pending = List< CopyCommand>()
86
- let mutable totalSize = 0 L
86
+ let mutable totalSize = 0 UL
87
87
let mutable running = true
88
88
89
89
@@ -95,8 +95,8 @@ and CopyEngine(family: DeviceQueueFamily) =
95
95
let mutable minBatchSize = Mem( 1 UL <<< 60 )
96
96
let mutable maxBatchSize = Mem( 0 UL)
97
97
let enqueueMon = obj()
98
- let mutable vEnqueue = 0 L
99
- let mutable vDone = - 1 L
98
+ let mutable vEnqueue = 0 UL
99
+ let mutable vDone = 0 UL
100
100
let run ( _threadName : string ) ( queue : DeviceQueue ) () =
101
101
let device = queue.DeviceInterface
102
102
let fence = new Fence( device)
@@ -114,19 +114,19 @@ and CopyEngine(family: DeviceQueueFamily) =
114
114
lock lockObj ( fun () ->
115
115
116
116
if not running then
117
- empty, 0 L , 0 L
117
+ empty, 0 UL , 0 UL
118
118
else
119
119
while pending.Count = 0 && running do Monitor.Wait lockObj |> ignore
120
120
if not running then
121
- empty, 0 L , 0 L
122
- elif totalSize >= 0 L then
121
+ empty, 0 UL , 0 UL
122
+ elif totalSize >= 0 UL then
123
123
let mine = pending
124
124
let s = totalSize
125
125
pending <- List()
126
- totalSize <- 0 L
126
+ totalSize <- 0 UL
127
127
mine, vEnqueue, s
128
128
else
129
- empty, 0 L , 0 L
129
+ empty, 0 UL , 0 UL
130
130
)
131
131
132
132
if copies.Count > 0 then
@@ -234,7 +234,7 @@ and CopyEngine(family: DeviceQueueFamily) =
234
234
fence.Wait()
235
235
sw.Stop()
236
236
237
- if totalSize > 0 L then
237
+ if totalSize > 0 UL then
238
238
lock statLock ( fun () ->
239
239
let totalSize = Mem totalSize
240
240
maxBatchSize <- max maxBatchSize totalSize
@@ -304,23 +304,23 @@ and CopyEngine(family: DeviceQueueFamily) =
304
304
lock lockObj ( fun () ->
305
305
pending.AddRange commands
306
306
307
- let s = commands |> Seq.fold ( fun s c -> s + c.SizeInBytes) 0 L
307
+ let s = commands |> Seq.fold ( fun s c -> s + c.SizeInBytes) 0 UL
308
308
totalSize <- totalSize + s
309
309
310
310
Monitor.PulseAll lockObj
311
311
s
312
312
)
313
313
314
- if size > 0 L then () // trigger.Signal()
314
+ if size > 0 UL then () // trigger.Signal()
315
315
316
316
/// Enqueues the commands and waits for them to be submitted.
317
317
member x.EnqueueSafe ( commands : seq < CopyCommand >) =
318
318
let enq , size =
319
319
lock lockObj ( fun () ->
320
- vEnqueue <- vEnqueue + 1 L
320
+ vEnqueue <- vEnqueue + 1 UL
321
321
pending.AddRange commands
322
322
323
- let s = commands |> Seq.fold ( fun s c -> s + c.SizeInBytes) 0 L
323
+ let s = commands |> Seq.fold ( fun s c -> s + c.SizeInBytes) 0 UL
324
324
totalSize <- totalSize + s
325
325
326
326
Monitor.PulseAll lockObj
@@ -332,7 +332,7 @@ and CopyEngine(family: DeviceQueueFamily) =
332
332
while vDone < enq do
333
333
Monitor.Wait enqueueMon |> ignore
334
334
)
335
- if size > 0 L then () // trigger.Signal()
335
+ if size > 0 UL then () // trigger.Signal()
336
336
337
337
member x.Wait () =
338
338
let l = obj()
0 commit comments