private void EnsureQueryPoolSize() { // Allocate one timestamp query if (currentQueryPool == null || currentQueryIndex >= currentQueryPool.QueryCount) { currentQueryPool = allocator.GetQueryPool(QueryType.Timestamp, TimestampQueryPoolCapacity); currentQueryIndex = 0; } }
public void CmdResetQueryPool() { using (QueryPool queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Timestamp, 1))) { CommandBuffer.Begin(); CommandBuffer.CmdResetQueryPool(queryPool, 0, 1); CommandBuffer.End(); } }
public void CmdWriteTimestamp() { using (QueryPool queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Timestamp, 1))) { CommandBuffer.Begin(); CommandBuffer.CmdWriteTimestamp(PipelineStages.AllCommands, queryPool, 0); CommandBuffer.End(); } }
public void CmdBeginAndEndQuery() { using (QueryPool queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Occlusion, 1))) { CommandBuffer.Begin(); CommandBuffer.CmdBeginQuery(queryPool, 0); CommandBuffer.CmdEndQuery(queryPool, 0); CommandBuffer.End(); } }
public void Flush() { QueryPool pool = null; while (queryEvents.Count > 0) { var query = queryEvents.Peek(); // If the query is allocated from a new pool, read back it's data if (query.Pool != pool) { // Don't read back the pool we are currently recording to if (query.Pool == currentQueryPool) { return; } // If the pool is not ready yet, wait until next time if (!query.Pool.TryGetData(queryResults)) { return; } // Recycle the pool pool = query.Pool; allocator.ReleaseReference(pool); } // Remove successful queries queryEvents.Dequeue(); // Profile // An event with a key is a begin event if (query.ProfilingKey != null) { var profilingState = Profiler.New(query.ProfilingKey); profilingState.Begin(timeStamp: queryResults[query.Index]); profilingStates.Push(profilingState); } else { var profilingState = profilingStates.Pop(); profilingState.End(timeStamp: queryResults[query.Index]); } } }
public void BeginQuery(BufferedQuery query, QueryPool pool, bool needsReset) { if (needsReset) { EndRenderPass(); Gd.Api.CmdResetQueryPool(CommandBuffer, pool, 0, 1); lock (_pendingQueryResets) { _pendingQueryResets.Remove(query); // Might be present on here. } } Gd.Api.CmdBeginQuery(CommandBuffer, pool, 0, 0); _activeQueries.Add(pool); }
public void CmdCopyQueryPoolResults() { const long bufferSize = 256L; using (QueryPool queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Timestamp, 1))) using (Buffer buffer = Device.CreateBuffer(new BufferCreateInfo(bufferSize, BufferUsages.TransferDst))) using (DeviceMemory memory = Device.AllocateMemory(new MemoryAllocateInfo(bufferSize, 0))) { // Required to keep the validation layer happy. // Ideally we should allocate memory based on these requirements. buffer.GetMemoryRequirements(); buffer.BindMemory(memory); CommandBuffer.Begin(); CommandBuffer.CmdCopyQueryPoolResults(queryPool, 0, 1, buffer, 0, bufferSize); CommandBuffer.End(); } }
private static void allFunctionsCommented() { //Initial configuration QueryPool.Configure("{connectionString}", recycleConnectionAfterNCalls: 15); //Starts all queries in the pool, or one in specific QueryPool.Start(); QueryPool.Start(Guid.NewGuid()); //'Id' property of 'QueryPoolItem' class //Pauses all queries in the pool, or one in specific QueryPool.Pause(); QueryPool.Pause(Guid.NewGuid()); //'Id' property of 'QueryPoolItem' class //Resets all queries in the pool, or one in specific QueryPool.Reset(); QueryPool.Reset(Guid.NewGuid()); //'Id' property of 'QueryPoolItem' class //Kill the query pool and all instances inside of it. This is similar to a Dispose() QueryPool.Kill(); }
public void Dispose() { QueryPool pool = null; while (queryEvents.Count > 0) { var query = queryEvents.Dequeue(); if (query.Pool != pool) { pool = query.Pool; allocator.ReleaseReference(pool); } } if (currentQueryPool != pool) { allocator.ReleaseReference(currentQueryPool); } currentQueryPool = null; }
private static void execute() { int quantityParallel = 15; //Quantity of queries been executed in parallel int minSeconds = 5; //Min seconds for the delay between executions int maxSeconds = 15; //Max seconds for the delay between executions int recycleConnectionAfterNCalls = 10; //Recycle the SqlConnection after N calls for each query //Initial configuration QueryPool.Configure(_connectionString, recycleConnectionAfterNCalls); //Random generate for the delay between execution for the same query Random random = new Random(); //Creates and starts each query generated for (int i = 0; i < quantityParallel; i++) { var item = new QueryPoolItem(); item.Query = "SELECT TOP 1 * FROM TABLE"; item.FrequencyInSeconds = random.Next(minSeconds, maxSeconds); item.QueryExecutedCallback = new Action <QueryResult>((queryResult) => { System.Console.WriteLine($"Item: {queryResult.Success} ({DateTime.Now})"); }); QueryPool.Add(item, startNow: true); } //If you want, you can add more items in pool while the pool is exexuting var newItem = new QueryPoolItem(); newItem.Query = "SELECT TOP 1 * FROM TABLE"; newItem.FrequencyInSeconds = 5; newItem.QueryExecutedCallback = new Action <QueryResult>((queryResult) => { System.Console.WriteLine($"New Item: {queryResult.Success} ({DateTime.Now})"); }); //Add item to the existing pool and start it! QueryPool.Add(newItem, startNow: true); }
internal static unsafe extern void vkCmdWriteTimestamp(CommandBuffer commandBuffer, PipelineStageFlags pipelineStage, QueryPool queryPool, uint query);
public abstract void CmdWriteAccelerationStructuresProperties([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint accelerationStructureCount, [Count(Computed = "accelerationStructureCount"), Flow(FlowDirection.In)] ref AccelerationStructureKHR pAccelerationStructures, [Count(Count = 0)] QueryType queryType, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint firstQuery);
/// <summary>To be documented.</summary> public static unsafe void CmdWriteAccelerationStructuresProperties(this NVRayTracing thisApi, [Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] uint accelerationStructureCount, [Count(Parameter = "accelerationStructureCount"), Flow(FlowDirection.In)] ReadOnlySpan <AccelerationStructureNV> pAccelerationStructures, [Count(Count = 0)] QueryType queryType, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint firstQuery) { // SpanOverloader thisApi.CmdWriteAccelerationStructuresProperties(commandBuffer, accelerationStructureCount, in pAccelerationStructures.GetPinnableReference(), queryType, queryPool, firstQuery); }
internal static unsafe extern Result vkGetQueryPoolResults(Device device, QueryPool queryPool, uint firstQuery, uint queryCount, PointerSize dataSize, IntPtr data, ulong stride, QueryResultFlags flags);
internal static unsafe extern void vkCmdResetQueryPool(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 firstQuery, UInt32 queryCount);
internal static unsafe extern void vkCmdCopyQueryPoolResults(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 firstQuery, UInt32 queryCount, Buffer dstBuffer, DeviceSize dstOffset, DeviceSize stride, QueryResultFlags flags);
public abstract void ResetQueryPool([Count(Count = 0)] Device device, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint firstQuery, [Count(Count = 0)] uint queryCount);
internal static unsafe extern void vkCmdBeginQuery(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 query, QueryControlFlags flags);
internal static unsafe extern void vkCmdBeginQuery(CommandBuffer commandBuffer, QueryPool queryPool, uint query, QueryControlFlags flags);
public void EndQuery(QueryPool pool) { Gd.Api.CmdEndQuery(CommandBuffer, pool, 0); _activeQueries.Remove(pool); }
public unsafe void CopyQueryPoolResults(QueryPool queryPool, uint firstQuery, uint queryCount, Buffer destinationBuffer, ulong destinationOffset, ulong stride, QueryResultFlags flags) { vkCmdCopyQueryPoolResults(this, queryPool, firstQuery, queryCount, destinationBuffer, destinationOffset, stride, flags); }
public unsafe void GetQueryPoolResults(QueryPool queryPool, uint firstQuery, uint queryCount, PointerSize dataSize, IntPtr data, ulong stride, QueryResultFlags flags) { vkGetQueryPoolResults(this, queryPool, firstQuery, queryCount, dataSize, data, stride, flags).CheckError(); }
public unsafe void DestroyQueryPool(QueryPool queryPool, AllocationCallbacks* allocator = null) { vkDestroyQueryPool(this, queryPool, allocator); }
internal static unsafe extern void vkDestroyQueryPool(Device device, QueryPool queryPool, AllocationCallbacks *Allocator);
public unsafe void WriteTimestamp(PipelineStageFlags pipelineStage, QueryPool queryPool, uint query) { vkCmdWriteTimestamp(this, pipelineStage, queryPool, query); }
internal static unsafe extern Result vkGetQueryPoolResults(Device device, QueryPool queryPool, UInt32 firstQuery, UInt32 queryCount, UIntPtr dataSize, out IntPtr Data, DeviceSize stride, QueryResultFlags flags);
internal static unsafe extern void vkDestroyQueryPool(Device device, QueryPool queryPool, AllocationCallbacks* allocator);
internal static unsafe extern void vkCmdEndQuery(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 query);
public partial void ResetQueryPool([Count(Count = 0)] Device device, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint firstQuery, [Count(Count = 0)] uint queryCount);
internal static unsafe extern void vkCmdWriteTimestamp(CommandBuffer commandBuffer, PipelineStageFlags pipelineStage, QueryPool queryPool, UInt32 query);
public unsafe void ResetQueryPool(QueryPool queryPool, uint firstQuery, uint queryCount) { vkCmdResetQueryPool(this, queryPool, firstQuery, queryCount); }
public abstract void CmdEndQueryIndexed([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint query, [Count(Count = 0)] uint index);
internal static unsafe extern void vkCmdEndQuery(CommandBuffer commandBuffer, QueryPool queryPool, uint query);
public unsafe void EndQuery(QueryPool queryPool, uint query) { vkCmdEndQuery(this, queryPool, query); }
public unsafe void BeginQuery(QueryPool queryPool, uint query, QueryControlFlags flags) { vkCmdBeginQuery(this, queryPool, query, flags); }
internal static unsafe extern void vkCmdCopyQueryPoolResults(CommandBuffer commandBuffer, QueryPool queryPool, uint firstQuery, uint queryCount, Buffer destinationBuffer, ulong destinationOffset, ulong stride, QueryResultFlags flags);
internal static unsafe extern void vkCmdResetQueryPool(CommandBuffer commandBuffer, QueryPool queryPool, uint firstQuery, uint queryCount);
public partial void CmdBeginQueryIndexed([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint query, [Count(Count = 0)] QueryControlFlags flags, [Count(Count = 0)] uint index);
internal static unsafe extern Result vkCreateQueryPool(Device device, QueryPoolCreateInfo* createInfo, AllocationCallbacks* allocator, QueryPool* queryPool);