Files
Seele/src/Engine/Graphics/Vulkan/Query.h
T

67 lines
2.1 KiB
C++
Raw Normal View History

2024-06-11 16:55:20 +02:00
#pragma once
2024-07-01 12:17:04 +02:00
#include "Buffer.h"
2024-06-11 16:55:20 +02:00
#include "Graphics.h"
#include "Graphics/Query.h"
namespace Seele {
namespace Vulkan {
2024-06-15 21:47:20 +02:00
class QueryPool {
public:
2024-07-01 12:17:04 +02:00
QueryPool(PGraphics graphics, VkQueryType type, VkQueryPipelineStatisticFlags flags, uint32 resultsStride, uint32 numBuffered,
const std::string& name);
2024-06-15 21:47:20 +02:00
virtual ~QueryPool();
void begin();
void end();
// stalls for the currently first pending query, dont call in render thread
void getQueryResults(Array<uint64>& results);
2024-09-03 11:03:23 +02:00
void createPool();
2024-06-15 21:47:20 +02:00
protected:
PGraphics graphics;
2024-09-03 11:03:23 +02:00
List<VkQueryPool> pools;
VkQueryType type;
std::string name;
2024-06-15 21:47:20 +02:00
VkQueryPipelineStatisticFlags flags;
2024-07-01 12:17:04 +02:00
// ring buffer
uint64 head = 0;
uint64 tail = 0;
2024-09-03 11:03:23 +02:00
uint64 numAvailable;
2024-06-15 21:47:20 +02:00
uint32 numQueries;
uint32 resultsStride;
2024-06-20 21:57:26 +02:00
std::mutex queryMutex;
std::condition_variable queryCV;
2024-06-15 21:47:20 +02:00
};
class OcclusionQuery : public Gfx::OcclusionQuery, public QueryPool {
2024-06-11 16:55:20 +02:00
public:
2024-07-01 12:17:04 +02:00
OcclusionQuery(PGraphics graphics, const std::string& name);
2024-06-11 16:55:20 +02:00
virtual ~OcclusionQuery();
virtual void beginQuery() override;
virtual void endQuery() override;
2024-06-15 21:47:20 +02:00
virtual Gfx::OcclusionResult getResults() override;
2024-06-11 16:55:20 +02:00
};
DEFINE_REF(OcclusionQuery)
2024-06-15 21:47:20 +02:00
class PipelineStatisticsQuery : public Gfx::PipelineStatisticsQuery, public QueryPool {
public:
2024-07-01 12:17:04 +02:00
PipelineStatisticsQuery(PGraphics graphics, const std::string& name);
2024-06-15 21:47:20 +02:00
virtual ~PipelineStatisticsQuery();
virtual void beginQuery() override;
virtual void endQuery() override;
virtual Gfx::PipelineStatisticsResult getResults() override;
};
DEFINE_REF(PipelineStatisticsQuery)
2024-07-01 12:17:04 +02:00
class TimestampQuery : public Gfx::TimestampQuery, public QueryPool {
public:
2024-09-03 11:03:23 +02:00
TimestampQuery(PGraphics graphics, const std::string& name);
2024-07-01 12:17:04 +02:00
virtual ~TimestampQuery();
virtual void write(Gfx::SePipelineStageFlagBits stage, const std::string& name = "") override;
2024-09-03 11:03:23 +02:00
virtual Gfx::Timestamp getResult() override;
2024-07-01 12:17:04 +02:00
private:
uint64 wrapping = 0;
uint64 lastMeasure = 0;
2024-09-03 11:03:23 +02:00
List<std::string> pendingTimestamps;
2024-07-01 12:17:04 +02:00
};
DEFINE_REF(TimestampQuery)
2024-06-11 16:55:20 +02:00
} // namespace Vulkan
} // namespace Seele