diff --git a/source/renderer/backend/IDevice.h b/source/renderer/backend/IDevice.h index 9b97558576..3697a3362e 100644 --- a/source/renderer/backend/IDevice.h +++ b/source/renderer/backend/IDevice.h @@ -61,6 +61,8 @@ public: uint32_t maxTextureSize; bool instancing; bool storage; + bool timestamps; + double timestampMultiplier; }; virtual ~IDevice() {} @@ -177,6 +179,32 @@ public: virtual Format GetPreferredDepthStencilFormat( const uint32_t usage, const bool depth, const bool stencil) const = 0; + virtual uint32_t AllocateQuery() = 0; + + virtual void FreeQuery(const uint32_t handle) = 0; + + /** + * @see GetQueryResult + * + * It must be called only if the query was submitted via + * IDeviceCommandContext::Flush. + * + * @param handle Must be a valid handle of a query. + * + * @return True if a result for the query is available. + */ + virtual bool IsQueryResultAvailable(const uint32_t handle) const = 0; + + /** + * After a call of the function the query result becomes invalid. + * + * @param handle Must be a valid handle of a query. + * + * @return A result for the query. The result is undefined if the query isn't + * ready. + */ + virtual uint64_t GetQueryResult(const uint32_t handle) = 0; + virtual const Capabilities& GetCapabilities() const = 0; }; diff --git a/source/renderer/backend/IDeviceCommandContext.h b/source/renderer/backend/IDeviceCommandContext.h index 57f606b8af..334564f16b 100644 --- a/source/renderer/backend/IDeviceCommandContext.h +++ b/source/renderer/backend/IDeviceCommandContext.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2024 Wildfire Games. +/* Copyright (C) 2025 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -222,6 +222,17 @@ public: virtual void SetUniform( const int32_t bindingSlot, PS::span values) = 0; + /** + * Insert a timestamp query which can be later requested via IDevice. + * @see IDevice::IsQueryResultAvailable + * It can be used only outside of a framebuffer pass. The query must + * not be used till Flush. + * + * @param handle Must be a valid handle to a query. + * @param isScopeBegin True if it's a scope start. + */ + virtual void InsertTimestampQuery(const uint32_t handle, const bool isScopeBegin) = 0; + virtual void BeginScopedLabel(const char* name) = 0; virtual void EndScopedLabel() = 0;