Skip to content

Commit

Permalink
Add warning for copy method
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed May 3, 2024
1 parent d61f381 commit 00ff88b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/mtl/command_enc/blit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ function MTLBlitCommandEncoder(f::Base.Callable, cmdbuf::MTLCommandBuffer)
end

##
function _check_size_or_offset(sizeOrOffset, argname::String)
(sizeOrOffset % 4 == 0) ||
@warn lazy"According to the official Metal documentation, $(argname) must be a multiple of 4. Proceed at your own risk." maxlog=1
return
end
# Copy from device to device
function append_copy!(enc::MTLBlitCommandEncoder, dst::MTLBuffer, doff,
src::MTLBuffer, soff, len)
_check_size_or_offset(sizeof(dst), "\"dst\" size")
_check_size_or_offset(doff, "\"doff\"")
_check_size_or_offset(sizeof(src), "\"src\" size")
_check_size_or_offset(soff, "\"soff\"")

@objc [enc::id{MTLBlitCommandEncoder} copyFromBuffer:src::id{MTLBuffer}
sourceOffset:soff::Csize_t
toBuffer:dst::id{MTLBuffer}
Expand Down

0 comments on commit 00ff88b

Please sign in to comment.