Page 1 of 1

OFX: MTLBuffer size for OFX plugins?

PostPosted: Thu Nov 19, 2020 5:25 pm
by Bart Walczak
Hi everyone,

I'm trying to blit the contents of the MTLBuffer that I get as the input clip into a texture, and the size of the buffer seems not to match the texture size.

For 1920x1080 32-bit float RGBA I'm getting the buffer length of 33,554,432, while it should be about 7.9 times larger. This is the assertion that I get:

Code: Select all
-[MTLDebugBlitCommandEncoder validateCopyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:options:]:768: failed assertion `totalBytesUsed(265205760) must be <= [sourceBuffer length](33554432).'


When I make this call:
Code: Select all
EncodeCopyBuffer:(id<MTLBuffer>)src
               toTexture:(id<MTLTexture>)dst
                    into:(id<MTLCommandBuffer>)commandBuffer
{
    auto info = texInfo(dst); // extracts info about texture

    [blitEncoder copyFromBuffer:src
                       sourceOffset:0
                  sourceBytesPerRow:info.bytesPerRow
                sourceBytesPerImage:info.bytesPerRow * dst.height
                         sourceSize:MTLSizeMake(dst.width, dst.height, dst.depth)
                          toTexture:dst
                   destinationSlice:0
                   destinationLevel:0
                  destinationOrigin:MTLOriginMake(0, 0, 0)];

Re: OFX: MTLBuffer size for OFX plugins?

PostPosted: Thu Nov 19, 2020 6:08 pm
by Hendrik Proosa
The size you get in assertion is exactly the size of 2048x1024 pixel 32bit float RGBA as bytes. Are you sure about your resolution and buffer length math?

Re: OFX: MTLBuffer size for OFX plugins?

PostPosted: Thu Nov 19, 2020 6:23 pm
by Bart Walczak
Hendrik Proosa wrote:The size you get in assertion is exactly the size of 2048x1024 pixel 32bit float RGBA as bytes. Are you sure about your resolution and buffer length math?


Ah, indeed, I had the rowBytes in bits not bytes. Thanks!

Re: OFX: MTLBuffer size for OFX plugins?

PostPosted: Fri Dec 04, 2020 8:24 pm
by gene JACQUES
Greetings

does any one know or have a ofx plugin or a developed tool similar to photoshop selective color tool that's works or act and behaves more or less similar to the photoshop like selective color unless its not been thought off or considered

would appreciate if any one could point me in the right direction
much appreciated

Re: OFX: MTLBuffer size for OFX plugins?

PostPosted: Fri Dec 04, 2020 11:57 pm
by Bruce Payan
Bart Walczak wrote:
Hendrik Proosa wrote:The size you get in assertion is exactly the size of 2048x1024 pixel 32bit float RGBA as bytes. Are you sure about your resolution and buffer length math?


Ah, indeed, I had the rowBytes in bits not bytes. Thanks!


One thing about the rowBytes.... if your buffer was, say, 2048x1018, your row bytes will still be the same (with unused bytes on each row), and CVPixelBuffer would expect a 2048x1024 sized buffer. It used to be that it would round up on 4-byte intervals -- but I believe it's now 16-byte intervals now with 128-bit intrinsics, This is why one always enquires CoreVideo about the number of rowBytes to a buffer. That issue has nipped a few people in the past. *ahem*.