mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-27 18:25:35 +00:00
query_cache: Address feedback
This commit is contained in:
parent
54a00ee4cf
commit
6d3a046caa
|
@ -62,7 +62,7 @@ public:
|
||||||
|
|
||||||
/// Returns true when the counter stream is enabled.
|
/// Returns true when the counter stream is enabled.
|
||||||
bool IsEnabled() const {
|
bool IsEnabled() const {
|
||||||
return static_cast<bool>(current);
|
return current != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -163,6 +163,11 @@ public:
|
||||||
return streams[static_cast<std::size_t>(type)];
|
return streams[static_cast<std::size_t>(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the counter stream of the specified type.
|
||||||
|
const CounterStream& Stream(VideoCore::QueryType type) const {
|
||||||
|
return streams[static_cast<std::size_t>(type)];
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::array<QueryPool, VideoCore::NumQueryTypes> query_pools;
|
std::array<QueryPool, VideoCore::NumQueryTypes> query_pools;
|
||||||
|
|
||||||
|
@ -219,7 +224,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr std::uintptr_t PAGE_SIZE = 4096;
|
static constexpr std::uintptr_t PAGE_SIZE = 4096;
|
||||||
static constexpr int PAGE_SHIFT = 12;
|
static constexpr unsigned PAGE_SHIFT = 12;
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
VideoCore::RasterizerInterface& rasterizer;
|
VideoCore::RasterizerInterface& rasterizer;
|
||||||
|
@ -237,13 +242,14 @@ public:
|
||||||
explicit HostCounterBase(std::shared_ptr<HostCounter> dependency_)
|
explicit HostCounterBase(std::shared_ptr<HostCounter> dependency_)
|
||||||
: dependency{std::move(dependency_)}, depth{dependency ? (dependency->Depth() + 1) : 0} {
|
: dependency{std::move(dependency_)}, depth{dependency ? (dependency->Depth() + 1) : 0} {
|
||||||
// Avoid nesting too many dependencies to avoid a stack overflow when these are deleted.
|
// Avoid nesting too many dependencies to avoid a stack overflow when these are deleted.
|
||||||
static constexpr u64 depth_threshold = 96;
|
constexpr u64 depth_threshold = 96;
|
||||||
if (depth > depth_threshold) {
|
if (depth > depth_threshold) {
|
||||||
depth = 0;
|
depth = 0;
|
||||||
base_result = dependency->Query();
|
base_result = dependency->Query();
|
||||||
dependency = nullptr;
|
dependency = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
virtual ~HostCounterBase() = default;
|
||||||
|
|
||||||
/// Returns the current value of the query.
|
/// Returns the current value of the query.
|
||||||
u64 Query() {
|
u64 Query() {
|
||||||
|
@ -257,7 +263,8 @@ public:
|
||||||
dependency = nullptr;
|
dependency = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *(result = value);
|
result = value;
|
||||||
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true when flushing this query will potentially wait.
|
/// Returns true when flushing this query will potentially wait.
|
||||||
|
@ -285,20 +292,13 @@ class CachedQueryBase {
|
||||||
public:
|
public:
|
||||||
explicit CachedQueryBase(VAddr cpu_addr, u8* host_ptr)
|
explicit CachedQueryBase(VAddr cpu_addr, u8* host_ptr)
|
||||||
: cpu_addr{cpu_addr}, host_ptr{host_ptr} {}
|
: cpu_addr{cpu_addr}, host_ptr{host_ptr} {}
|
||||||
|
virtual ~CachedQueryBase() = default;
|
||||||
|
|
||||||
CachedQueryBase(CachedQueryBase&& rhs) noexcept
|
CachedQueryBase(CachedQueryBase&&) noexcept = default;
|
||||||
: cpu_addr{rhs.cpu_addr}, host_ptr{rhs.host_ptr}, counter{std::move(rhs.counter)},
|
|
||||||
timestamp{rhs.timestamp} {}
|
|
||||||
|
|
||||||
CachedQueryBase(const CachedQueryBase&) = delete;
|
CachedQueryBase(const CachedQueryBase&) = delete;
|
||||||
|
|
||||||
CachedQueryBase& operator=(CachedQueryBase&& rhs) noexcept {
|
CachedQueryBase& operator=(CachedQueryBase&&) noexcept = default;
|
||||||
cpu_addr = rhs.cpu_addr;
|
CachedQueryBase& operator=(const CachedQueryBase&) = delete;
|
||||||
host_ptr = rhs.host_ptr;
|
|
||||||
counter = std::move(rhs.counter);
|
|
||||||
timestamp = rhs.timestamp;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Flushes the query to guest memory.
|
/// Flushes the query to guest memory.
|
||||||
virtual void Flush() {
|
virtual void Flush() {
|
||||||
|
@ -335,7 +335,7 @@ public:
|
||||||
return SizeInBytes(timestamp.has_value());
|
return SizeInBytes(timestamp.has_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64 SizeInBytes(bool with_timestamp) {
|
static constexpr u64 SizeInBytes(bool with_timestamp) noexcept {
|
||||||
return with_timestamp ? LARGE_QUERY_SIZE : SMALL_QUERY_SIZE;
|
return with_timestamp ? LARGE_QUERY_SIZE : SMALL_QUERY_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,10 @@ public:
|
||||||
explicit CachedQuery(QueryCache& cache, VideoCore::QueryType type, VAddr cpu_addr,
|
explicit CachedQuery(QueryCache& cache, VideoCore::QueryType type, VAddr cpu_addr,
|
||||||
u8* host_ptr);
|
u8* host_ptr);
|
||||||
CachedQuery(CachedQuery&& rhs) noexcept;
|
CachedQuery(CachedQuery&& rhs) noexcept;
|
||||||
|
CachedQuery(const CachedQuery&) = delete;
|
||||||
|
|
||||||
CachedQuery& operator=(CachedQuery&& rhs) noexcept;
|
CachedQuery& operator=(CachedQuery&& rhs) noexcept;
|
||||||
|
CachedQuery& operator=(const CachedQuery&) = delete;
|
||||||
|
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue