예제 #1
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;
        }
예제 #2
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();
        }
예제 #3
0
 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];
     }
 }
예제 #4
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;
        }
예제 #5
0
 private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     this.HeapObjects           = pool.Entries;
     this.DescriptorStartOffset = pool.Allocate(desc.ElementCount);
 }
예제 #6
0
 public static DescriptorSet New(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     return(new DescriptorSet(graphicsDevice, pool, desc));
 }
예제 #7
0
 private DescriptorSet(GraphicsDevice graphicsDevice, DescriptorPool pool, DescriptorSetLayout desc)
 {
     GraphicsDevice      = graphicsDevice;
     NativeDescriptorSet = pool.AllocateDescriptorSet(desc);
 }