public int GetChunkIndex(int2 startIndex) { int2 result; if (poolDict.Get(startIndex, out result)) { return(result.y); } return(-1); }
public static T GetEvent <T>() where T : PipelineEvent { Type type = typeof(T); int value; if (eventsGuideBook.Get(new UIntPtr(MUnsafeUtility.GetManagedPtr(type)), out value)) { return(current.resources.availiableEvents[value] as T); } return(null); }
public static ComputeBuffer GetTempPropertyBuffer(int length, int stride, ComputeBufferType type = ComputeBufferType.Default) { if (!allTempBuffers.isCreated) { allTempBuffers = new NativeDictionary <BufferKey, int, BufferKey.Equal>(11, Allocator.Persistent, new BufferKey.Equal()); } ComputeBuffer target; int targetIndex; if (allTempBuffers.Get(new BufferKey { size = stride, type = type }, out targetIndex)) { target = MUnsafeUtility.GetHookedObject(targetIndex) as ComputeBuffer; if (target.count < length) { target.Dispose(); target = new ComputeBuffer(length, stride, type); MUnsafeUtility.SetHookedObject(targetIndex, target); } return(target); } else { target = new ComputeBuffer(length, stride); allTempBuffers[new BufferKey { size = stride, type = type }] = MUnsafeUtility.HookObject(target); return(target); } }
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); }