Beispiel #1
0
        public void CreateIndirectDrawCommands(BucketManager bucketManager, InstanceDataBuffer instanceData)
        {
            foreach (var commandBuffer in PrimitiveIndirectDrawBuffer.Values)
            {
                if (commandBuffer.Count > 0)
                {
                    return;
                }
                commandBuffer.Clear( );
            }

            foreach (var part in InstanceManager.Parts)
            {
                var bucket        = bucketManager.GetBucketResource(part);
                var primitiveType = part.PrimitiveType;

                var bufferKey = new IndirectCommandBufferKey(bucket, primitiveType);

                if (!PrimitiveIndirectDrawBuffer.ContainsKey(bufferKey))
                {
                    PrimitiveIndirectDrawBuffer[bufferKey] = new IndirectDrawCommandBuffer(primitiveType, bucket);
                }
                PrimitiveIndirectDrawBuffer[bufferKey].AddDrawCommand(part, bucket,
                                                                      instanceData[part]);
            }

            foreach (var indirectDrawCommandBuffers in PrimitiveIndirectDrawBuffer.Values)
            {
                indirectDrawCommandBuffers.CreateCommandBuffer( );
            }
        }
Beispiel #2
0
 public void DispatchDraws(InstanceDataBuffer instanceData)
 {
     foreach (var drawCommandBuffer in PrimitiveIndirectDrawBuffer.Values)
     {
         using (drawCommandBuffer.Bind( ))
             using (drawCommandBuffer.SourceBucket.Bind( ))
                 using (instanceData.Bind( ))
                 {
                     GL.MultiDrawElementsIndirect(
                         ( All )drawCommandBuffer.PrimitiveType,
                         All.UnsignedShort,
                         IntPtr.Zero,
                         drawCommandBuffer.Count,
                         0);
                 }
     }
 }
 public Handle(InstanceDataBuffer instanceDataBuffer)
 {
     target = instanceDataBuffer;
     target.Instances.Clear( );
 }
 public BindHandle(InstanceDataBuffer instanceDataBuffer)
 {
     GL.BindVertexBuffer(7, instanceDataBuffer.BufferId, ( IntPtr )0, Vector4.SizeInBytes * 4);
 }