1 /* 2 * Copyright (C) 2023 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 API_RENDER_UTIL_IRENDER_UTIL_H 17 #define API_RENDER_UTIL_IRENDER_UTIL_H 18 19 #include <cstdint> 20 21 #include <render/namespace.h> 22 #include <render/resource_handle.h> 23 24 RENDER_BEGIN_NAMESPACE() 25 /** @ingroup group_util_irenderutil */ 26 27 /** 28 * Render timings 29 */ 30 struct RenderTimings { 31 struct Times { 32 /** Time stamp at the beginning of RenderFrame() */ 33 int64_t begin { 0 }; 34 /** Time stamp at the end of RenderFrame() */ 35 int64_t end { 0 }; 36 37 /** Time stamp at the beginning of backend command list processing */ 38 int64_t beginBackend { 0 }; 39 /** Time stamp at the beginning of backend presentation start */ 40 int64_t beginBackendPresent { 0 }; 41 /** Time stamp at the end of backend command list processing and submits */ 42 int64_t endBackend { 0 }; 43 }; 44 /** Current results after RenderFrame() has returned */ 45 Times frame; 46 /** Previous frame results after RenderFrame() has returned */ 47 Times prevFrame; 48 }; 49 50 /** Interface for rendering utilities. 51 */ 52 class IRenderUtil { 53 public: 54 /** Get description for given handle. 55 * @param handle Render handle reference of the resource. 56 * @return RenderHandleDesc Return render handle desc for given handle. 57 */ 58 virtual RenderHandleDesc GetRenderHandleDesc(const RenderHandleReference& handle) const = 0; 59 60 /** Get handle for given description. 61 * @param desc Render handle description. 62 * @return RenderHandleReference Return render handle for given desc. 63 */ 64 virtual RenderHandleReference GetRenderHandle(const RenderHandleDesc& desc) const = 0; 65 66 /** Get last render timings. Should be usually called after RenderFrame() has returned. 67 * @return RenderTimings Results from the last RenderFrame() call. 68 */ 69 virtual RenderTimings GetRenderTimings() const = 0; 70 71 protected: 72 IRenderUtil() = default; 73 virtual ~IRenderUtil() = default; 74 }; 75 RENDER_END_NAMESPACE() 76 77 #endif // API_RENDER_UTIL_IRENDER_UTIL_H 78