From 8d82adb3d39b276f83cdbd26762ff0e8c43c1a16 Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Sun, 21 Jan 2024 13:39:35 +0200 Subject: [PATCH] glsl_shader_gen: Remove invariant qualifier (#7376) * glsl_shader_gen: Remove invariant qualifier * Causes visual regressions in Pokemon with RADV * rasterizer_cache: Clear null surface to transparent --- src/video_core/rasterizer_cache/rasterizer_cache.h | 10 ++++++++++ src/video_core/shader/generator/glsl_shader_gen.cpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/video_core/rasterizer_cache/rasterizer_cache.h b/src/video_core/rasterizer_cache/rasterizer_cache.h index b6c4dd4f6..16027fd93 100644 --- a/src/video_core/rasterizer_cache/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache/rasterizer_cache.h @@ -67,6 +67,16 @@ RasterizerCache::RasterizerCache(Memory::MemorySystem& memory_, .wrap_s = TextureConfig::WrapMode::ClampToBorder, .wrap_t = TextureConfig::WrapMode::ClampToBorder, })); + + auto& null_surface = slot_surfaces[NULL_SURFACE_ID]; + runtime.ClearTexture(null_surface, { + .texture_level = 0, + .texture_rect = null_surface.GetScaledRect(), + .value = + { + .color = {0.f, 0.f, 0.f, 0.f}, + }, + }); } template diff --git a/src/video_core/shader/generator/glsl_shader_gen.cpp b/src/video_core/shader/generator/glsl_shader_gen.cpp index 10cab49b3..82c0486d0 100644 --- a/src/video_core/shader/generator/glsl_shader_gen.cpp +++ b/src/video_core/shader/generator/glsl_shader_gen.cpp @@ -76,7 +76,13 @@ static std::string GetVertexInterfaceDeclaration(bool is_output, bool use_clip_p if (is_output && separable_shader) { // gl_PerVertex redeclaration is required for separate shader object out += "out gl_PerVertex {\n"; + // Apple Silicon GPU drivers optimize more aggressively, which can create + // too much variance and cause visual artifacting in games like Pokemon. +#ifdef __APPLE__ out += " invariant vec4 gl_Position;\n"; +#else + out += " vec4 gl_Position;\n"; +#endif if (use_clip_planes) { out += " float gl_ClipDistance[2];\n"; }