Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

texture_cache return invalid buffer on deactivated color_mask

Fernando Sahmkow4298dc8290a3
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 2d6fd154aa..2872dbdebc 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -370,10 +370,12 @@ void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey,
return;
if (fbkey.is_single_buffer) {
- if (fbkey.color_attachments[0] != GL_NONE) {
+ if (fbkey.color_attachments[0] != GL_NONE && fbkey.colors[0]) {
fbkey.colors[0]->Attach(fbkey.color_attachments[0]);
+ glDrawBuffer(fbkey.color_attachments[0]);
+ } else {
+ glDrawBuffer(GL_NONE);
}
- glDrawBuffer(fbkey.color_attachments[0]);
} else {
for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
if (fbkey.colors[index]) {
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 1b8ada9101..7058399e24 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -133,6 +133,11 @@ public:
return {};
}
+ if (regs.color_mask[index].raw != 0) {
+ SetEmptyColorBuffer(index);
+ return {};
+ }
+
const auto& config{regs.rt[index]};
const auto gpu_addr{config.Address()};
if (!gpu_addr) {