ios - How to set a CVPixelBuffer as an input for a vertex shader? -



ios - How to set a CVPixelBuffer as an input for a vertex shader? -

i utilize apple metal render path processing cvpixelbuffer.

how can transform cvpixelbuffer conform input vertex shader? not sure how extract color/position values cvpixelbuffer able setting them host.

here's code utilize convert cvpixelbuffer info metal texture.

#pragma mark - avcapturevideodataoutputsamplebufferdelegate - (void)captureoutput:(avcaptureoutput *)captureoutput didoutputsamplebuffer:(cmsamplebufferref)samplebuffer fromconnection:(avcaptureconnection *)connection { cvpixelbufferref pixelbuffer = cmsamplebuffergetimagebuffer(samplebuffer); id<mtltexture> texture = nil; { size_t width = cvpixelbuffergetwidth(pixelbuffer); size_t height = cvpixelbuffergetheight(pixelbuffer); mtlpixelformat pixelformat = mtlpixelformatbgra8unorm; cvmetaltextureref metaltextureref = null; cvreturn status = cvmetaltexturecachecreatetexturefromimage(null, _texturecache, pixelbuffer, null, pixelformat, width, height, 0, &metaltextureref); if(status == kcvreturnsuccess) { texture = cvmetaltexturegettexture(metaltextureref); if (self.delegate){ [self.delegate textureupdated:texture]; } cfrelease(metaltextureref); } } }

after have texture, pass rendercommandencoder. if need help that, allow me know in comments.

ios rendering metal

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -