Hello, is there a way to directly draw to a Metal ...
# compose-ios
p
Hello, is there a way to directly draw to a Metal texture that a shader (in a separate, custom library) can manipulate?
By 'draw' I mean
DrawScope
draw calls. In Android I can do this:
Copy code
val androidSurface: android.view.Surface = getHWSurfaceFromSomewher()
val androidCanvas = surface.lockHardwareCanvas()

val canvas = Canvas(androidCanvas)
CanvasDrawScope().draw(
        canvas = canvas
) {
    //DrawScope draw calls
}
        surface.unlockCanvasAndPost(androidCanvas)
// drawing has been rendered to texture
For iOS it seems like I could do something like:
Copy code
val tex = device!!.newTextureWithDescriptor(texDescriptor)

//what is this???
val texturePtr

val renderTarget = BackendRenderTarget.makeMetal(width, height, texturePtr)
val skiaSurface = Surface.makeFromBackendRenderTarget(rt = renderTarget)
val composeCanvas = skiaSurface?.canvas?.asComposeCanvas()
But I do not know what to pass in for
texturePtr
to
BackendRenderTarget.makeMetal
.
I know I could render to a bitmap using
Canvas(bitmap)
, and then copy the pixels to a texture. But the extra copy seems less than ideal vs letting the skia backend draw directly to the texture. Thoughts?