Back to Filament

render

docs/android/dokka/filament-android/com.google.android.filament/-renderer/render.md

1.75.02.0 KB
Original Source

//filament-android/com.google.android.filament/Renderer/render

render

[main]
open fun render(view: View)

Renders a View into this Renderer's window.

This is filament's main rendering method, most of the CPU-side heavy lifting is performed here. The purpose of the render() function is to generate render commands which are asynchronously executed by the Engine's render thread.

render() generates commands for each of the following stages:

  • Shadow map passes, if needed
  • Depth pre-pass
  • SSAO pass, if enabled
  • Color pass
  • Post-processing pass

A typical render loop looks like this:

kotlin
void renderLoop(Renderer renderer, SwapChain swapChain) {
    do {
        // typically we wait for VSYNC and user input events
        if (renderer.beginFrame(swapChain)) {
            renderer.render(mView);
            renderer.endFrame();
        }
    } while (!quit());
}

  • render() must be called afterbeginFrame and beforeendFrame.
  • render() must be called from the Engine's main thread (or external synchronization must be provided). In particular, calls to render() on different Renderer instances must be synchronized.
  • render() performs potentially heavy computations and cannot be multi-threaded. However, internally, it is highly multi-threaded to both improve performance and mitigate the call's latency.
  • render() is typically called once per frame (but not necessarily).

Parameters

main

viewthe View to render

See also

beginFrame
endFrame
View

Throws

Errorif the backend thread encountered an unrecoverable error, or if called again after a backend exception was already thrown.