1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef VULKAN_GPU_QUERY_VK_H 17 #define VULKAN_GPU_QUERY_VK_H 18 19 #include <vulkan/vulkan_core.h> 20 21 #include <base/containers/vector.h> 22 #include <render/namespace.h> 23 24 #include "perf/gpu_query.h" 25 26 RENDER_BEGIN_NAMESPACE() 27 class Device; 28 29 struct GpuQueryPlatformDataVk : public GpuQueryPlatformData { 30 VkQueryPool queryPool { VK_NULL_HANDLE }; 31 }; 32 33 /** GpuQueryVk. */ 34 class GpuQueryVk final : public GpuQuery { 35 public: 36 GpuQueryVk(Device& device, const GpuQueryDesc& desc); 37 ~GpuQueryVk(); 38 39 void NextQueryIndex() override; 40 41 const GpuQueryDesc& GetDesc() const override; 42 const GpuQueryPlatformData& GetPlatformData() const override; 43 44 private: 45 Device& device_; 46 47 static constexpr const uint32_t QUERY_COUNT_PER_POOL { 2 }; 48 49 uint32_t queryIndex_ { 0 }; 50 BASE_NS::vector<GpuQueryPlatformDataVk> plats_; 51 GpuQueryDesc desc_; 52 }; 53 BASE_NS::unique_ptr<GpuQuery> CreateGpuQueryVk(Device& device, const GpuQueryDesc& desc); 54 RENDER_END_NAMESPACE() 55 56 #endif // VULKAN_GPU_QUERY_VK_H 57