public SyncC(CarSocket socket, RenderTexture renderTexture, FPSLogger logger) { this.socket = socket; this.renderTexture = renderTexture; virtualPhoto = new Texture2D((int)socket.imageWidth, (int)socket.imageHeight, TextureFormat.RGB24, false); this.logger = logger; }
public AsyncC(CarSocket socket, RenderTexture renderTexture, FPSLogger logger) { this.socket = socket; this.logger = logger; this.renderTexture = renderTexture; for (int i = 0; i < readers.Length; ++i) { readers[i] = new GPUReader((int)socket.imageWidth * (int)socket.imageHeight); } }
private void Start() { mCamera = GetComponent <Camera>(); mCamera.enabled = ShouldEnableCamera; if (!mCamera.enabled) { return; } if (socket == null) { Debug.LogWarning("Camera enabled, but socket missing"); return; } renderTexture = new RenderTexture((int)socket.imageWidth, (int)socket.imageHeight, 24, RenderTextureFormat.ARGB32); renderTexture.antiAliasing = 2; Debug.Log("CameraOutputController started"); mCamera.rect = new Rect(0, 0, 1, 1); mCamera.aspect = 1.0f * socket.imageWidth / socket.imageHeight; mCamera.targetTexture = renderTexture; RenderPipelineManager.endFrameRendering += OnEndFrameRendering; bool async = SystemInfo.supportsAsyncGPUReadback; Debug.Log("Async GPU Readback supported: " + async); logger = FindObjectOfType <FPSLogger>(); if (socket is CarSocket s) { if (async) { this.c = new AsyncC(s, renderTexture, logger); } else { // TODO: Async GPU doesn't currently work, needs a re-impl. this.c = new SyncC(s, renderTexture, logger); } } else if (socket is WebCarSocket ws) { this.c = new WebC(ws, renderTexture, logger); } EventBus.Subscribe <CarRemoved>(this, e => logger.Remove(e.car)); }
private void Start() { mCamera = GetComponent <Camera>(); renderTexture = new RenderTexture((int)CarSocket.IMAGE_WIDTH, (int)CarSocket.IMAGE_HEIGHT, 24, RenderTextureFormat.ARGB32); renderTexture.antiAliasing = 2; for (int i = 0; i < readers.Length; ++i) { readers[i] = new GPUReader((int)CarSocket.IMAGE_WIDTH * (int)CarSocket.IMAGE_HEIGHT); } virtualPhoto = new Texture2D((int)CarSocket.IMAGE_WIDTH, (int)CarSocket.IMAGE_HEIGHT, TextureFormat.RGB24, false); Debug.Log("CameraOutputController started"); mCamera.rect = new Rect(0, 0, 1, 1); mCamera.aspect = 1.0f * CarSocket.IMAGE_WIDTH / CarSocket.IMAGE_HEIGHT; mCamera.targetTexture = renderTexture; mCamera.enabled = ShouldEnableCamera; RenderPipelineManager.endFrameRendering += OnEndFrameRendering; this.async = SystemInfo.supportsAsyncGPUReadback; Debug.Log("Async GPU Readback supported: " + this.async); logger = FindObjectOfType <FPSLogger>(); }