Adds an interface for queries.

This commit is contained in:
Vladislav Belov 2025-04-16 22:38:24 +02:00
parent 8da6c758fc
commit 0e7d193fcc
No known key found for this signature in database
GPG key ID: 353545E45DB9CCB3
2 changed files with 40 additions and 1 deletions

View file

@ -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;
};

View file

@ -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<const float> 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;