private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc) { if (pool.SrvOffset + desc.SrvCount > pool.SrvCount || pool.SamplerOffset + desc.SamplerCount > pool.SamplerCount) { // Eearly exit if OOM, IsValid should return false (TODO: different mechanism?) Device = null; BindingOffsets = null; Description = null; SrvStart = new CpuDescriptorHandle(); SamplerStart = new CpuDescriptorHandle(); return; } Device = graphicsDevice; BindingOffsets = desc.BindingOffsets; Description = desc; // Store start CpuDescriptorHandle SrvStart = desc.SrvCount > 0 ? (pool.SrvStart + graphicsDevice.SrvHandleIncrementSize * pool.SrvOffset) : new CpuDescriptorHandle(); SamplerStart = desc.SamplerCount > 0 ? (pool.SamplerStart + graphicsDevice.SamplerHandleIncrementSize * pool.SamplerOffset) : new CpuDescriptorHandle(); // Allocation is done, bump offsets // TODO D3D12 thread safety? pool.SrvOffset += desc.SrvCount; pool.SamplerOffset += desc.SamplerCount; }
protected override void Destroy() { foreach (var descriptorPool in descriptorPools) { descriptorPool.Dispose(); } descriptorPools.Clear(); currentDescriptorPool = null; foreach (var bufferPool in bufferPools) { bufferPool.Dispose(); } bufferPools.Clear(); currentBufferPool = null; base.Destroy(); }
private void SetupNextDescriptorPool() { currentDescriptorPoolIndex++; if (currentDescriptorPoolIndex >= descriptorPools.Count) { descriptorPools.Add(currentDescriptorPool = DescriptorPool.New(graphicsDevice, new[] { new DescriptorTypeCount(EffectParameterClass.ConstantBuffer, 16384), new DescriptorTypeCount(EffectParameterClass.ShaderResourceView, 65536), new DescriptorTypeCount(EffectParameterClass.UnorderedAccessView, 4096), new DescriptorTypeCount(EffectParameterClass.Sampler, 16384), })); } else { currentDescriptorPool = descriptorPools[currentDescriptorPoolIndex]; } }
public void Reset(CommandList commandList) { this.commandList = commandList; foreach (var descriptorPool in descriptorPools) { descriptorPool.Reset(); } foreach (var bufferPool in bufferPools) { bufferPool.Reset(); } currentResourceGroupPoolIndex = -1; currentDescriptorPool = descriptorPools[0]; currentDescriptorPoolIndex = 0; currentBufferPool = null; currentBufferPoolIndex = -1; }
private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc) { this.HeapObjects = pool.Entries; this.DescriptorStartOffset = pool.Allocate(desc.ElementCount); }
public static DescriptorSet New(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc) { return(new DescriptorSet(graphicsDevice, pool, desc)); }
private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc) { GraphicsDevice = graphicsDevice; NativeDescriptorSet = pool.AllocateDescriptorSet(desc); }