ios - CAMetalLayer drawable texture is weird on some devices -


image metal layer

i using below code , append pixel buffer metal layer. on non specific devices output looks below , drawable textures pixelformat .invalid

static func make(with currentdrawable: cametaldrawable, usingbuffer pool: cvpixelbufferpool) -> (cvpixelbuffer?, uiimage) {        let destinationtexture = currentdrawable.texture        var pixelbuffer: cvpixelbuffer?       _ = cvpixelbufferpoolcreatepixelbuffer(kcfallocatordefault, pool, &pixelbuffer)       if let pixelbuffer = pixelbuffer {         cvpixelbufferlockbaseaddress(pixelbuffer, cvpixelbufferlockflags.init(rawvalue: 0))         let region = mtlregionmake2d(0, 0, int(currentdrawable.layer.drawablesize.width), int(currentdrawable.layer.drawablesize.height))          let bytesperrow = cvpixelbuffergetbytesperrow(pixelbuffer)          let tempbuffer = cvpixelbuffergetbaseaddress(pixelbuffer)         destinationtexture.getbytes(tempbuffer!, bytesperrow: int(bytesperrow), from: region, mipmaplevel: 0)          let image = imagefromcvpixelbuffer(buffer: pixelbuffer)         cvpixelbufferunlockbaseaddress(pixelbuffer, cvpixelbufferlockflags.init(rawvalue: 0))         return (pixelbuffer, image)       }       return (nil, uiimage())     }   static func imagefromcvpixelbuffer(buffer: cvpixelbuffer) -> uiimage {        let ciimage = ciimage(cvpixelbuffer: buffer)       let cgimgage = context.createcgimage(ciimage, from: cgrect(x: 0, y: 0, width: cvpixelbuffergetwidth(buffer), height: cvpixelbuffergetheight(buffer)))        let uiimage = uiimage(cgimage: cgimgage!)        return uiimage     } 

does have idea why happens , how prevent it?

there several more feedback people experiencing can found here: https://github.com/svtek/scenekitvideorecorder/issues/3


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -