I am getting an error from the graphics driver while converting the EnvironmentTexture(from ARKIT.AREnvironmentProbeAnchor) to CVPixelBuffer. The EnvironmentTexture is an IMTLTexture. I am using Xamarin.iOS.
This is the code that I use to convert the IMTLTexture to CVPixelBuffer.
The error I am getting from the driver is AGX: Texture read/write assertion failed: bytes_per_row >= used_bytes_per_row
I tried with different values of pixelBuffer.BytesPerRow but still getting the error. Can someone help me?
This is the code that I use to convert the IMTLTexture to CVPixelBuffer.
Code Block buffers[i] = new CVPixelBuffer((nint)epAnchor.EnvironmentTexture.Width, (nint)epAnchor.EnvironmentTexture.Height, CVPixelFormatType.CV32RGBA); GetEnvironmentTextureSlice(buffers[i], epAnchor.EnvironmentTexture, i); public void GetEnvironmentTextureSlice(CVPixelBuffer pixelBuffer, Metal.IMTLTexture texture, int id) { Metal.MTLRegion mtlRegion = Metal.MTLRegion.Create2D((nuint)0, 0, 256, 256); nuint bytesPerPixel = 4; nuint bytesPerRow = bytesPerPixel * (nuint)mtlRegion.Size.Width; // (nuint)pixelBuffer.BytesPerRow; nuint bytesPerImage = bytesPerRow * (nuint)mtlRegion.Size.Height; pixelBuffer.Lock(CVPixelBufferLock.None); texture.GetBytes(pixelBuffer.BaseAddress, (nuint)pixelBuffer.BytesPerRow, mtlRegion, 0); pixelBuffer.Unlock(CVPixelBufferLock.None); }
The error I am getting from the driver is AGX: Texture read/write assertion failed: bytes_per_row >= used_bytes_per_row
I tried with different values of pixelBuffer.BytesPerRow but still getting the error. Can someone help me?