/// <summary> /// Draws a geometry batch /// </summary> /// <param name="batch">Bztch of geometric shapes</param> internal void DrawInstancedGeometry(InstanceBatch batch) { if (batch.InstanceCount == 0) return; RenderingInfo renderInfo = batch.RenderInfo; _graphicDevice.SetVertexBuffers(renderInfo.VertexData.VertexBindings); IndexData indexData = renderInfo.IndexData; _graphicDevice.Indices = indexData.HardwareBuffer; _graphicDevice.DrawInstancedPrimitives(renderInfo.PrimitiveType, 0, 0, renderInfo.VertexCount, indexData.StartIndex, renderInfo.PrimitiveCount, batch.InstanceCount); UnsetBuffers(); int instanceCount = batch.InstanceCount; FrameDetail.AddDrawCall((uint)(renderInfo.VertexCount * instanceCount), (uint)(renderInfo.PrimitiveCount * instanceCount), (uint)instanceCount); }
/// <summary> /// Get an InstanceBatch /// </summary> /// <param name="id">Id of the batch</param> /// <param name="queueId">Queue Id</param> /// <returns>Return an InstanceBatch instance</returns> private InstanceBatch GetInstanceBatch(uint id, int queueId) { Dictionary<uint, InstanceBatch> map = _batchByQueue[queueId] ?? AddNewMap(queueId); InstanceBatch batch; map.TryGetValue(id, out batch); if (batch != null) return batch; batch = new InstanceBatch(_owner.GraphicsDevice, id, queueId); map.Add(id, batch); _batchs.Add(batch); return batch; }