void Update() { if (_firstUpdate) { initDataForTex(ref _data, blittingScript.renderTex); _previewTexture = new Texture2D(blittingScript.renderTex.width, blittingScript.renderTex.height); _previewTexture.filterMode = FilterMode.Point; resultMaterial.SetTexture("_MainTex", _previewTexture); Glint.requestWaitTimeInFrames = 1; Glint.RequestAsync(blittingScript.renderTex, _data, onDataRetrieved); _firstUpdate = false; } }
// Callback that calls itself, for continuous (sequential, non-optimal) download. private void onDataRetrieved() { // Upon getting the callback, we look at the data and fill it into a texture // to display on the "CPU" side of the scene. fillTextureWithData(_data, blittingScript.renderTex.width, blittingScript.renderTex.height, _previewTexture); _sb.Remove(0, _sb.Length); _sb.Append("Render thread map (ms):\t"); _sb.Append(Glint.Profiling.lastRenderMapMs.ToString("F3")); _sb.Append("\n"); _sb.Append("Render thread memcpy (ms):\t"); _sb.Append(Glint.Profiling.lastRenderCopyMs.ToString("F3")); _sb.Append("\n"); _sb.Append("Main thread memcpy (ms):\t"); _sb.Append(Glint.Profiling.lastMainCopyMs.ToString("F3")); textMesh.text = _sb.ToString(); Glint.RequestAsync(blittingScript.renderTex, _data, onDataRetrieved); }