public RenderPipeline(PipelineResources resources) { eventsGuideBook = new NativeDictionary <UIntPtr, int, PtrEqual>(resources.availiableEvents.Length, Allocator.Persistent, new PtrEqual()); resources.SetRenderingPath(); var allEvents = resources.allEvents; GraphicsUtility.UpdatePlatform(); MLight.ClearLightDict(); this.resources = resources; current = this; data.buffer = new CommandBuffer(); for (int i = 0; i < resources.availiableEvents.Length; ++i) { resources.availiableEvents[i].InitDependEventsList(); } for (int i = 0; i < resources.availiableEvents.Length; ++i) { eventsGuideBook.Add(new UIntPtr(MUnsafeUtility.GetManagedPtr(resources.availiableEvents[i].GetType())), i); resources.availiableEvents[i].Prepare(); } for (int i = 0; i < resources.availiableEvents.Length; ++i) { resources.availiableEvents[i].InitEvent(resources); } waitReleaseRT = new NativeList <int>(20, Allocator.Persistent); }
public static void AddRunnableObject(int id, IPipelineRunnable func) { if (!iRunnableObjects.isCreated) { iRunnableObjects = new NativeDictionary <int, ulong, IntEqual>(10, Allocator.Persistent, new IntEqual()); } iRunnableObjects.Add(id, (ulong)MUnsafeUtility.GetManagedPtr(func)); }
private void OnEnable() { if (!allCamera.isCreated) { allCamera = new NativeDictionary <int, UIntPtr>(17, Unity.Collections.Allocator.Persistent, (i, j) => i == j); } allCamera.Add(gameObject.GetInstanceID(), new UIntPtr(MUnsafeUtility.GetManagedPtr(this))); }
private void OnEnable() { if (!allCamera.isCreated) { allCamera = new NativeDictionary <int, UIntPtr, IntEqual>(17, Allocator.Persistent, new IntEqual()); } allCamera.Add(gameObject.GetInstanceID(), new UIntPtr(MUnsafeUtility.GetManagedPtr(this))); GetComponent <Camera>().layerCullDistances = layerCullDistance; }
public override void FrameUpdate(PipelineCamera cam, ref PipelineCommandData data) { if (!enabledPost || !cam.postProfile) { data.buffer.Blit(cam.targets.renderTargetIdentifier, cam.cameraTarget); return; } #if UNITY_EDITOR if (!enableInEditor && RenderPipeline.renderingEditor) { data.buffer.Blit(cam.targets.renderTargetIdentifier, cam.cameraTarget); return; } #endif NativeDictionary <ulong, ulong, PtrEqual> allSettings = new NativeDictionary <ulong, ulong, PtrEqual>(allPostEffects.Count, Unity.Collections.Allocator.Temp, new PtrEqual()); foreach (var i in cam.postProfile.settings) { allSettings.Add((ulong)MUnsafeUtility.GetManagedPtr(i.GetType()), (ulong)MUnsafeUtility.GetManagedPtr(i)); } postContext.camera = cam.cam; postContext.command = data.buffer; postContext.sourceFormat = RenderTextureFormat.ARGBHalf; postContext.autoExposureTexture = RuntimeUtilities.whiteTexture; postContext.bloomBufferNameID = -1; RenderTargetIdentifier source, dest; postContext.source = cam.targets.renderTargetIdentifier; postContext.destination = cam.targets.backupIdentifier; postContext.logHistogram.Generate(postContext); cyberGlitch.Render(data.buffer, ref cam.targets); foreach (var i in allPostEffects) { ulong settingsPtr; if (allSettings.Get((ulong)MUnsafeUtility.GetManagedPtr(i.type), out settingsPtr)) { PostProcessEffectSettings setting = MUnsafeUtility.GetObject <PostProcessEffectSettings>((void *)settingsPtr); if (i.needBlit && setting.active) { PipelineFunctions.RunPostProcess(ref cam.targets, out source, out dest); postContext.source = source; postContext.destination = dest; } i.renderer.SetSettings(setting); i.renderer.Render(postContext); } } ; allSettings.Dispose(); // data.buffer.Blit(ShaderIDs._CameraMotionVectorsTexture, cam.cameraTarget); // data.buffer.BlitSRT(cam.cameraTarget, debugMat, 0); data.buffer.BlitSRT(cam.targets.renderTargetIdentifier, cam.cameraTarget, postContext.uberSheet.material, 0, postContext.uberSheet.properties); if (postContext.bloomBufferNameID > -1) { data.buffer.ReleaseTemporaryRT(postContext.bloomBufferNameID); } }
public AssetReference GetReference(ref int4x4 guid) { if (!referenceCacheDict.isCreated) { referenceCacheDict = new NativeDictionary <int4x4, int, Int4x4Equal>(100, Allocator.Persistent, new Int4x4Equal()); } int index; if (referenceCacheDict.Get(guid, out index)) { return(allReferenceCache[index]); } string guidCache = new string((char *)guid.Ptr(), 0, 32); referenceCacheDict.Add(guid, allReferenceCache.Count); AssetReference aref = new AssetReference(guidCache); allReferenceCache.Add(aref); return(aref); }
private bool GetChunk(ref int2 startIndex, int size, out int element) { startIndex %= indexSize; int2 result; if (poolDict.Get(startIndex, out result)) { if (result.x != size) { result = int2(size, result.y); poolDict[startIndex] = result; } element = result.y; return(true); } bool res = pool.Get(out element); result = int2(size, element); poolDict.Add(startIndex, result); return(res); }