Exemplo n.º 1
0
 private void EnsureQueryPoolSize()
 {
     // Allocate one timestamp query
     if (currentQueryPool == null || currentQueryIndex >= currentQueryPool.QueryCount)
     {
         currentQueryPool  = allocator.GetQueryPool(QueryType.Timestamp, TimestampQueryPoolCapacity);
         currentQueryIndex = 0;
     }
 }
Exemplo n.º 2
0
 public void CmdResetQueryPool()
 {
     using (QueryPool queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Timestamp, 1)))
     {
         CommandBuffer.Begin();
         CommandBuffer.CmdResetQueryPool(queryPool, 0, 1);
         CommandBuffer.End();
     }
 }
Exemplo n.º 3
0
 public void CmdWriteTimestamp()
 {
     using (QueryPool queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Timestamp, 1)))
     {
         CommandBuffer.Begin();
         CommandBuffer.CmdWriteTimestamp(PipelineStages.AllCommands, queryPool, 0);
         CommandBuffer.End();
     }
 }
Exemplo n.º 4
0
 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();
     }
 }
Exemplo n.º 5
0
        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]);
                }
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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();
                    }
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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;
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 internal static unsafe extern void vkCmdWriteTimestamp(CommandBuffer commandBuffer, PipelineStageFlags pipelineStage, QueryPool queryPool, uint query);
Exemplo n.º 12
0
 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);
Exemplo n.º 13
0
 /// <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);
 }
Exemplo n.º 14
0
 internal static unsafe extern Result vkGetQueryPoolResults(Device device, QueryPool queryPool, uint firstQuery, uint queryCount, PointerSize dataSize, IntPtr data, ulong stride, QueryResultFlags flags);
Exemplo n.º 15
0
 internal static unsafe extern void vkCmdResetQueryPool(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 firstQuery, UInt32 queryCount);
Exemplo n.º 16
0
 internal static unsafe extern void vkCmdCopyQueryPoolResults(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 firstQuery, UInt32 queryCount, Buffer dstBuffer, DeviceSize dstOffset, DeviceSize stride, QueryResultFlags flags);
Exemplo n.º 17
0
 public abstract void ResetQueryPool([Count(Count = 0)] Device device, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint firstQuery, [Count(Count = 0)] uint queryCount);
Exemplo n.º 18
0
 internal static unsafe extern void vkCmdBeginQuery(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 query, QueryControlFlags flags);
Exemplo n.º 19
0
 internal static unsafe extern void vkCmdBeginQuery(CommandBuffer commandBuffer, QueryPool queryPool, uint query, QueryControlFlags flags);
Exemplo n.º 20
0
        public void EndQuery(QueryPool pool)
        {
            Gd.Api.CmdEndQuery(CommandBuffer, pool, 0);

            _activeQueries.Remove(pool);
        }
Exemplo n.º 21
0
 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);
 }
Exemplo n.º 22
0
 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();
 }
Exemplo n.º 23
0
 public unsafe void DestroyQueryPool(QueryPool queryPool, AllocationCallbacks* allocator = null)
 {
     vkDestroyQueryPool(this, queryPool, allocator);
 }
Exemplo n.º 24
0
 internal static unsafe extern void vkDestroyQueryPool(Device device, QueryPool queryPool, AllocationCallbacks *Allocator);
Exemplo n.º 25
0
 public unsafe void WriteTimestamp(PipelineStageFlags pipelineStage, QueryPool queryPool, uint query)
 {
     vkCmdWriteTimestamp(this, pipelineStage, queryPool, query);
 }
Exemplo n.º 26
0
 internal static unsafe extern Result vkGetQueryPoolResults(Device device, QueryPool queryPool, UInt32 firstQuery, UInt32 queryCount, UIntPtr dataSize, out IntPtr Data, DeviceSize stride, QueryResultFlags flags);
Exemplo n.º 27
0
 internal static unsafe extern void vkDestroyQueryPool(Device device, QueryPool queryPool, AllocationCallbacks* allocator);
Exemplo n.º 28
0
 internal static unsafe extern void vkCmdEndQuery(CommandBuffer commandBuffer, QueryPool queryPool, UInt32 query);
Exemplo n.º 29
0
 public partial void ResetQueryPool([Count(Count = 0)] Device device, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint firstQuery, [Count(Count = 0)] uint queryCount);
Exemplo n.º 30
0
 internal static unsafe extern void vkCmdWriteTimestamp(CommandBuffer commandBuffer, PipelineStageFlags pipelineStage, QueryPool queryPool, UInt32 query);
Exemplo n.º 31
0
 public unsafe void ResetQueryPool(QueryPool queryPool, uint firstQuery, uint queryCount)
 {
     vkCmdResetQueryPool(this, queryPool, firstQuery, queryCount);
 }
Exemplo n.º 32
0
 public abstract void CmdEndQueryIndexed([Count(Count = 0)] CommandBuffer commandBuffer, [Count(Count = 0)] QueryPool queryPool, [Count(Count = 0)] uint query, [Count(Count = 0)] uint index);
Exemplo n.º 33
0
 internal static unsafe extern void vkCmdEndQuery(CommandBuffer commandBuffer, QueryPool queryPool, uint query);
Exemplo n.º 34
0
 public unsafe void EndQuery(QueryPool queryPool, uint query)
 {
     vkCmdEndQuery(this, queryPool, query);
 }
Exemplo n.º 35
0
 public unsafe void BeginQuery(QueryPool queryPool, uint query, QueryControlFlags flags)
 {
     vkCmdBeginQuery(this, queryPool, query, flags);
 }
Exemplo n.º 36
0
 internal static unsafe extern void vkCmdCopyQueryPoolResults(CommandBuffer commandBuffer, QueryPool queryPool, uint firstQuery, uint queryCount, Buffer destinationBuffer, ulong destinationOffset, ulong stride, QueryResultFlags flags);
Exemplo n.º 37
0
 internal static unsafe extern void vkCmdResetQueryPool(CommandBuffer commandBuffer, QueryPool queryPool, uint firstQuery, uint queryCount);
Exemplo n.º 38
0
 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);
Exemplo n.º 39
0
 internal static unsafe extern Result vkCreateQueryPool(Device device, QueryPoolCreateInfo* createInfo, AllocationCallbacks* allocator, QueryPool* queryPool);