/*public bool UpdatePix2Pix() { * bool done = false; * // Advance the Pix2Pix inference until the current budget runs out. * for (var cost = 0.0f; cost < _budget;) { * if (!_generator.Running) _generator.Start(_sourceTexture); * * cost += _generator.Step(); * * if (!_generator.Running) { * _generator.GetResult(_resultTexture); * done = true; * } * } * * Pix2Pix.GpuBackend.ExecuteAndClearCommandBuffer(); * * // Review the budget depending on the current frame time. * _budget -= (Time.deltaTime * 60 - 1.25f) * _budgetAdjust; * _budget = Mathf.Clamp(_budget, 150, 1200); * * _budgetAdjust = Mathf.Max(_budgetAdjust - 0.05f, 0.5f); * * // Update the text display. * var rate = 60 * _budget / 1000; * * var perf = (_budgetAdjust < 1) ? * _performanceLabels[(int)Mathf.Min(5, _budget / 100)] : * "Measuring GPU performance..."; * * // _textUI.text = * // string.Format("pix2Pix refresh rate: {0:F1} Hz", rate); * return done; * }*/ #endregion public void Render(RenderTexture source, RenderTexture output) { // if (_generator == null || !isInitialized) InitializePix2Pix(); // Debug.Log(string.Format("{0}, {1}", source == null, _generator == null)); _generator.Start(source); _generator.Step(); while (_generator.Running) { _generator.Step(); } _generator.GetResult(output); Pix2Pix.GpuBackend.ExecuteAndClearCommandBuffer(); }
void UpdatePix2Pix() { // Advance the Pix2Pix inference until the current budget runs out. for (var cost = 0.0f; cost < _budget;) { if (!_generator.Running) { _generator.Start(_sourceTexture); } cost += _generator.Step(); if (!_generator.Running) { _generator.GetResult(_resultTexture); } } // Review the budget depending on the current frame time. _budget -= (Time.deltaTime * 60 - 1.25f) * _budgetAdjust; _budget = Mathf.Clamp(_budget, 150, 1200); _budgetAdjust = Mathf.Max(_budgetAdjust - 0.05f, 0.5f); // Update the text display. var rate = 60 * _budget / 1000; var perf = (_budgetAdjust < 1) ? _performanceLabels[(int)Mathf.Min(5, _budget / 100)] : "Measuring GPU performance..."; _textUI.text = string.Format("Pix2Pix refresh rate: {0:F1} Hz ({1})", rate, perf); }
public bool UpdatePix2Pix() { bool done = false; // Advance the Pix2Pix inference until the current budget runs out. for (var cost = 0.0f; cost < _budget;) { if (!_generator.Running) { _generator.Start(_sourceTexture); } cost += _generator.Step(); if (!_generator.Running) { _generator.GetResult(_resultTexture); done = true; } } Pix2Pix.GpuBackend.ExecuteAndClearCommandBuffer(); // Review the budget depending on the current frame time. _budget -= (Time.deltaTime * 60 - 1.25f) * _budgetAdjust; _budget = Mathf.Clamp(_budget, 150, 1200); _budgetAdjust = Mathf.Max(_budgetAdjust - 0.05f, 0.5f); // Update the text display. var rate = 60 * _budget / 1000; var perf = (_budgetAdjust < 1) ? _performanceLabels[(int)Mathf.Min(5, _budget / 100)] : "Measuring GPU performance..."; // _textUI.text = // string.Format("pix2Pix refresh rate: {0:F1} Hz", rate); return(done); }