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;
        }
Exemplo n.º 2
0
        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;
        }
 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];
     }
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        public void Reset()
        {
            foreach (var descriptorPool in descriptorPools)
            {
                descriptorPool.Reset();
            }
            foreach (var bufferPool in bufferPools)
            {
                bufferPool.Reset();
            }

            currentResourceGroupPoolIndex = -1;

            currentDescriptorPool      = descriptorPools[0];
            currentDescriptorPoolIndex = 0;

            currentBufferPool      = bufferPools[0];
            currentBufferPoolIndex = 0;
        }
        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;
        }
        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;
        }
Exemplo n.º 8
0
 private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     this.HeapObjects           = pool.Entries;
     this.DescriptorStartOffset = pool.Allocate(desc.ElementCount);
 }
Exemplo n.º 9
0
 public static DescriptorSet New(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     return(new DescriptorSet(graphicsDevice, pool, desc));
 }
Exemplo n.º 10
0
 private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     this.HeapObjects = pool.Entries;
     this.DescriptorStartOffset = pool.Allocate(desc.ElementCount);
 }
Exemplo n.º 11
0
 public static DescriptorSet New(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     return new DescriptorSet(graphicsDevice, pool, desc);
 }
 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];
     }
 }
Exemplo n.º 13
0
 private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     GraphicsDevice      = graphicsDevice;
     NativeDescriptorSet = pool.AllocateDescriptorSet(desc);
 }