Ejemplo n.º 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( );
            }
        }
Ejemplo n.º 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);
                 }
     }
 }
Ejemplo n.º 3
0
 public Handle(InstanceDataBuffer instanceDataBuffer)
 {
     target = instanceDataBuffer;
     target.Instances.Clear( );
 }
Ejemplo n.º 4
0
 public BindHandle(InstanceDataBuffer instanceDataBuffer)
 {
     GL.BindVertexBuffer(7, instanceDataBuffer.BufferId, ( IntPtr )0, Vector4.SizeInBytes * 4);
 }