Beispiel #1
0
            public DataSet(Utility.GPUBufferType bufferType, uint totalCount, uint maxQueuedFrameCount, uint updateRangePoolSize, bool mockBuffer)
            {
                bool flag = !mockBuffer;

                if (flag)
                {
                    this.gpuData = new Utility.GPUBuffer <T>((int)totalCount, bufferType);
                }
                this.cpuData   = new NativeArray <T>((int)totalCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                this.allocator = new GPUBufferAllocator(totalCount);
                bool flag2 = !mockBuffer;

                if (flag2)
                {
                    this.m_ElemStride = (uint)this.gpuData.ElementStride;
                }
                this.m_UpdateRangePoolSize = updateRangePoolSize;
                uint length = this.m_UpdateRangePoolSize * maxQueuedFrameCount;

                this.updateRanges             = new NativeArray <GfxUpdateBufferRange>((int)length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                this.m_UpdateRangeMin         = 4294967295u;
                this.m_UpdateRangeMax         = 0u;
                this.m_UpdateRangesEnqueued   = 0u;
                this.m_UpdateRangesBatchStart = 0u;
            }
Beispiel #2
0
            public void SendFullRange()
            {
                uint num = (uint)((long)this.cpuData.Length * (long)((ulong)this.m_ElemStride));

                this.updateRanges[(int)this.m_UpdateRangesBatchStart] = new GfxUpdateBufferRange
                {
                    source = new UIntPtr(this.cpuData.GetUnsafeReadOnlyPtr <T>()),
                    offsetFromWriteStart = 0u,
                    size = num
                };
                Utility.GPUBuffer <T> expr_5F = this.gpuData;
                if (expr_5F != null)
                {
                    expr_5F.UpdateRanges(this.updateRanges.Slice((int)this.m_UpdateRangesBatchStart, 1), 0, (int)num);
                }
                this.ResetUpdateState();
            }
Beispiel #3
0
            public void Dispose(bool disposing)
            {
                bool disposed = this.disposed;

                if (!disposed)
                {
                    if (disposing)
                    {
                        Utility.GPUBuffer <T> expr_19 = this.gpuData;
                        if (expr_19 != null)
                        {
                            expr_19.Dispose();
                        }
                        this.cpuData.Dispose();
                        this.updateRanges.Dispose();
                    }
                    this.disposed = true;
                }
            }
Beispiel #4
0
            public void SendPartialRanges()
            {
                bool flag = this.m_UpdateRangesEnqueued == 0u;

                if (!flag)
                {
                    bool updateRangesSaturated = this.m_UpdateRangesSaturated;
                    if (updateRangesSaturated)
                    {
                        uint num = this.m_UpdateRangeMax - this.m_UpdateRangeMin;
                        this.m_UpdateRangesEnqueued = 1u;
                        this.updateRanges[(int)this.m_UpdateRangesBatchStart] = new GfxUpdateBufferRange
                        {
                            source = new UIntPtr(this.cpuData.Slice((int)this.m_UpdateRangeMin, (int)num).GetUnsafeReadOnlyPtr <T>()),
                            offsetFromWriteStart = this.m_UpdateRangeMin * this.m_ElemStride,
                            size = num * this.m_ElemStride
                        };
                    }
                    uint num2      = this.m_UpdateRangeMin * this.m_ElemStride;
                    uint rangesMax = this.m_UpdateRangeMax * this.m_ElemStride;
                    bool flag2     = num2 > 0u;
                    if (flag2)
                    {
                        for (uint num3 = 0u; num3 < this.m_UpdateRangesEnqueued; num3 += 1u)
                        {
                            int index = (int)(num3 + this.m_UpdateRangesBatchStart);
                            this.updateRanges[index] = new GfxUpdateBufferRange
                            {
                                source = this.updateRanges[index].source,
                                offsetFromWriteStart = this.updateRanges[index].offsetFromWriteStart - num2,
                                size = this.updateRanges[index].size
                            };
                        }
                    }
                    Utility.GPUBuffer <T> expr_15A = this.gpuData;
                    if (expr_15A != null)
                    {
                        expr_15A.UpdateRanges(this.updateRanges.Slice((int)this.m_UpdateRangesBatchStart, (int)this.m_UpdateRangesEnqueued), (int)num2, (int)rangesMax);
                    }
                    this.ResetUpdateState();
                }
            }
            public DataSet(Utility.GPUBufferType bufferType, uint totalCount, uint maxQueuedFrameCount, uint updateRangePoolSize, bool mockBuffer)
            {
                if (!mockBuffer)
                {
                    gpuData = new Utility.GPUBuffer <T>((int)totalCount, bufferType);
                }
                cpuData   = new NativeArray <T>((int)totalCount, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                allocator = new GPUBufferAllocator(totalCount);
                if (!mockBuffer)
                {
                    m_ElemStride = (uint)gpuData.ElementStride;
                }

                m_UpdateRangePoolSize = updateRangePoolSize;
                uint multipliedUpdateRangePoolSize = m_UpdateRangePoolSize * maxQueuedFrameCount;

                updateRanges             = new NativeArray <GfxUpdateBufferRange>((int)multipliedUpdateRangePoolSize, Allocator.Persistent, NativeArrayOptions.UninitializedMemory);
                m_UpdateRangeMin         = uint.MaxValue;
                m_UpdateRangeMax         = 0;
                m_UpdateRangesEnqueued   = 0;
                m_UpdateRangesBatchStart = 0;
            }