本文へスキップ

onProcessGpu()

onProcessGpu: ({ framework, frameStartResult })`.

説明

onProcessGpu()`はGPU処理を開始するために呼ばれる。

パラメータ

パラメータ説明
フレームワーク{dispatchEvent(eventName, detail) } : 与えられた詳細を持つ名前付きイベントを発行します。
フレーム開始結果{ cameraTexture, computeTexture, GLctx, computeCtx, textureWidth, textureHeight, orientation, videoTime, repeatFrame }.

frameStartResult`パラメータは以下のプロパティを持つ:

プロパティ説明
カメラテクスチャカメラフィードデータを含む描画キャンバスの WebGLTexture
計算テクスチャカメラフィードデータを含むコンピュートキャンバスの WebGLTexture
GLctx描画キャンバスの WebGLRenderingContext または WebGL2RenderingContext.
computeCtxコンピュートキャンバスの WebGLRenderingContext または WebGL2RenderingContext.
テクスチャ幅カメラフィードテクスチャの幅(ピクセル単位)。
テクスチャの高さカメラフィードテクスチャの高さ(ピクセル単位)。
オリエンテーションポートレートからのUIの回転を度単位で指定する(-90, 0, 90, 180)。
ビデオタイムこのビデオフレームのタイムスタンプ。
リピートフレームカメラのフィードが前回の呼び出し以降更新されていない場合は真。

{#returns}を返す。

onProcessCpu](onprocesscpu.md)と[onUpdate](onupdate.md)に提供したいデータは、 。 これは、processGpuResult.modulename`としてこれらのメソッドに提供される。

XR8.addCameraPipelineModule({
name: 'mycamerapipelinemodule',
onProcessGpu: ({frameStartResult}) => {
const {cameraTexture, GLctx, textureWidth, textureHeight} = frameStartResult

if(!cameraTexture.name){
console.error("[index] Camera texture does not have a name")
}

const restoreParams = XR8.GlTextureRenderer.getGLctxParameters(GLctx, [GLctx.TEXTURE0])
// ここで関連するGPU処理を行う
...
XR8.GlTextureRenderer.setGLctxParameters(GLctx, restoreParams)

// これらのフィールドはonProcessCpuとonUpdateに提供されます
return {gpuDataA, gpuDataB}
},
})