public RayIntersections(string name, uint maxCount, int deviceIndex) : base(name) { MaxRayCount = maxCount; RayBuffer = new StreamableBuffer(name + "_rays", maxCount * RaySize, BufferUsage.Storage); rayBufferPtr = RayBuffer.LocalBuffer.GetRayDevicePointer(0); HitBuffer = new StreamableBuffer(name + "_hits", maxCount * HitSize, BufferUsage.Storage); resultBufferPtr = HitBuffer.LocalBuffer.GetRayDevicePointer(0); //Allocate the necessary memory unsafe { ulong scratchSz = 0; if (rrGetTraceMemoryRequirements(GraphicsDevice.DeviceInformation[deviceIndex].RaysContext, maxCount, &scratchSz) != RRError.RrSuccess) { throw new Exception("Failed to determine trace memory requirements."); } ScratchBuffer = new GpuBuffer(name + "_scratch") { MemoryUsage = MemoryUsage.GpuOnly, Size = scratchSz, Usage = BufferUsage.Storage | BufferUsage.TransferDst }; ScratchBuffer.Build(deviceIndex); scratchBufferPtr = ScratchBuffer.GetRayDevicePointer(0); } }
public IndexedRenderQueue(string name, int max_cnt, IndexType idxType) { draws = new List <DrawData>(); this.idxType = idxType; maxDraws = max_cnt; IndirectBuffer = new StreamableBuffer(name, (ulong)(max_cnt * 16 + 4) * sizeof(uint), BufferUsage.Indirect | BufferUsage.Storage); }