diff --git a/runtime/gfx_shader.c b/runtime/gfx_shader.c index 231e4942..ebe2b488 100644 --- a/runtime/gfx_shader.c +++ b/runtime/gfx_shader.c @@ -874,6 +874,10 @@ static size_t build_request(char *o0, const char *hex, const char *stage, const else memcpy(l, control + 0x748, 12); o += sprintf(o, ",\"local\":[%u,%u,%u]", l[0], l[1], l[2]); } + /* Control byte +0x718 of a fragment shader: early fragment tests (the NVN driver's early-Z-force, MacNativeGames + ae8f4f4). Without it a shader that stores to memory is depth-tested late, and the G-buffer draws' EQUAL test + after the depth prepass fails along contour lines. Already part of the code hash (the whole control section). */ + if (!strcmp(stage, "ps") && (control[0x718] & 1)) o += sprintf(o, ",\"early_fragment_tests\":true"); int si = !strcmp(stage, "vs") ? 0 : !strcmp(stage, "cs") ? 2 : 1; // gfx_shader_set_host answers if (!host_f64) o += sprintf(o, ",\"softfloat64\":true"); if (host_sbuf) o += sprintf(o, ",\"sbuf_align\":%u", host_sbuf); diff --git a/tools/xlate/Program.cs b/tools/xlate/Program.cs index b2e89f7a..f0301d91 100644 --- a/tools/xlate/Program.cs +++ b/tools/xlate/Program.cs @@ -89,7 +89,10 @@ static class SwshXlate if (_job["fout"] is JsonObject f) foreach (var kv in f) fout[int.Parse(kv.Key)] = Attr((string)kv.Value); // Vulkan: VK_EXT_depth_clip_control handles NEAR_IS_MINUS_W, so the shader is never rewritten ("depth_minus_w" in a job is ignored). const bool depthMinusW = false; - return new GpuGraphicsState(false, InputTopology.Triangles, false, TessPatchType.Triangles, TessSpacing.EqualSpacing, + // "early_fragment_tests": the fragment shader's NVN control byte +0x718 (the driver's early-Z-force, Ryujinx's + // EarlyZForce); the SPIR-V then declares EarlyFragmentTests (MacNativeGames ae8f4f4). + bool earlyZ = _job["early_fragment_tests"] is JsonValue ez && ez.TryGetValue(out bool eb) && eb; + return new GpuGraphicsState(earlyZ, InputTopology.Triangles, false, TessPatchType.Triangles, TessSpacing.EqualSpacing, false, false, false, depthMinusW, false, 1f, AlphaTestOp.Always, 0f, attr, false, fout, false, false /* 不做 Y 取反 | no Y flip */, true /* 原点左上 | origin upper-left */, false); }