From 661375a222399f6b731362c849417a82a17531ee Mon Sep 17 00:00:00 2001
From: Kelebek1 <eeeedddccc@hotmail.co.uk>
Date: Tue, 30 May 2023 21:57:13 +0100
Subject: [PATCH] Skip BufferCache tickframe with no channel state set

---
 src/video_core/buffer_cache/buffer_cache.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index c336be7079..427afd5fc4 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -63,8 +63,12 @@ void BufferCache<P>::RunGarbageCollector() {
 
 template <class P>
 void BufferCache<P>::TickFrame() {
-    // Calculate hits and shots and move hit bits to the right
+    // Homebrew console apps don't create or bind any channels, so this will be nullptr.
+    if (!channel_state) {
+        return;
+    }
 
+    // Calculate hits and shots and move hit bits to the right
     const u32 hits = std::reduce(channel_state->uniform_cache_hits.begin(),
                                  channel_state->uniform_cache_hits.end());
     const u32 shots = std::reduce(channel_state->uniform_cache_shots.begin(),