2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2020 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2020-09-07 23:52:55 +02:00
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
|
* \ingroup gpu
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "BLI_span.hh"
|
|
|
|
|
|
|
|
|
|
namespace blender::gpu {
|
|
|
|
|
|
2022-02-12 21:52:24 -08:00
|
|
|
#define QUERY_MIN_LEN 16
|
|
|
|
|
|
2023-08-05 14:22:48 +10:00
|
|
|
enum GPUQueryType {
|
2020-09-07 23:52:55 +02:00
|
|
|
GPU_QUERY_OCCLUSION = 0,
|
2023-08-05 14:22:48 +10:00
|
|
|
};
|
2020-09-07 23:52:55 +02:00
|
|
|
|
|
|
|
|
class QueryPool {
|
|
|
|
|
public:
|
2024-10-31 15:18:29 +01:00
|
|
|
virtual ~QueryPool() = default;
|
2020-09-07 23:52:55 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Will start and end the query at this index inside the pool. The pool will resize
|
|
|
|
|
* automatically but does not support sparse allocation. So prefer using consecutive indices.
|
|
|
|
|
*/
|
|
|
|
|
virtual void init(GPUQueryType type) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Will start and end the query at this index inside the pool.
|
|
|
|
|
* The pool will resize automatically.
|
|
|
|
|
*/
|
2022-01-05 21:44:03 -05:00
|
|
|
virtual void begin_query() = 0;
|
|
|
|
|
virtual void end_query() = 0;
|
2020-09-07 23:52:55 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Must be fed with a buffer large enough to contain all the queries issued.
|
|
|
|
|
* IMPORTANT: Result for each query can be either binary or represent the number of samples
|
|
|
|
|
* drawn.
|
|
|
|
|
*/
|
|
|
|
|
virtual void get_occlusion_result(MutableSpan<uint32_t> r_values) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-02 09:48:41 +10:00
|
|
|
} // namespace blender::gpu
|