pcsx2 icon indicating copy to clipboard operation
pcsx2 copied to clipboard

[BUG]: Silent Hill 4 doesn't render 3d Graphics in macOS with Metal renderer GS:Metal

Open bloedmage opened this issue 1 year ago • 7 comments

Describe the Bug

Using the metal rendered all 3d graphics show a black screen. Menus are working. The game runs fine using vulkan through moltenVK.

Reproduction Steps

start the game, complete black screen when inside your room.

Expected Behavior

No response

PCSX2 Revision

1.7.4217

Operating System

macOS 10.15 (Catalina)

If Linux - Specify Distro

No response

CPU

i5-1035g7

GPU

Iris Plus G7

GS Settings

No response

Emulation Settings

No response

GS Window Screenshots

No response

Logs & Dumps

No response

bloedmage avatar Mar 12 '23 11:03 bloedmage

is it only Silent Hill 4? do other games work fine? do you get any errors in your emulog file (you may need to enable file logging), that would be useful?

refractionpcsx2 avatar Mar 12 '23 11:03 refractionpcsx2

I only encountered this bug in Silent Hill 4 so far. Other games ran fine using the metal renderer on intel integrated GPU.

This is the error I get in the log [ 31.9620] Failed to create pipeline HW Render 1a.0.40000020440102.f1: Compiler encountered an internal error

Played it for 2 minutes using Vulkan to the first save point. Loading the game with the metal renderer shows some textures though. Screenshot 2023-03-12 at 12 27 55

Same scene with Vulkan Screenshot 2023-03-12 at 12 32 41

bloedmage avatar Mar 12 '23 11:03 bloedmage

damn, that's it? it doesn't say anything else? :(

refractionpcsx2 avatar Mar 12 '23 11:03 refractionpcsx2

This is the full log, I started the game with Vulkan. The error starts when I switch to Metal, it just repeats indefinitely afterwards.

[ 0.1767] PCSX2 Nightly - v1.7.4217 Compiled on Mar 12 2023 [ 0.1767] Savestate version: 0x9a340000 [ 0.1767] [ 0.1767] Host Machine Init: [ 0.1768] Operating System = Darwin 19.6.0 x86_64 [ 0.1768] Physical RAM = 16384 MB [ 0.1778] CPU name = Intel(R) Core(TM) i5-1035G7 CPU @ 1.20GHz [ 0.1778] Vendor/Model = GenuineIntel (stepping 05) [ 0.1778] CPU speed = 1.497 ghz (1 logical thread) [ 0.1778] x86PType = Standard OEM [ 0.1778] x86Flags = bfebfbff 7ffafbbf [ 0.1778] x86EFlags = 2c100800 [ 0.1778] [ 0.1778] x86 Features Detected: [ 0.1778] AVX AVX2 [ 0.1778] [ 0.1784] Reserving memory for recompilers... [ 0.1836] Fastmem area: 0x167100000 - 0x2670fffff [ 1.0962] Scanning /Volumes/Untitled/Emulation/Sony - Playstation 2 (recursively) [ 1.0963] Scanning /Volumes/Bootcamp/Emulation/Sony - Playstation 2 (recursively) [ 1.2306] (SDLInputSource) Controller 0 inserted [ 1.2308] (SDLInputSource) Opened game controller 0 (instance id 0, player id 0): Xbox 360 Controller [ 1.2308] (SDLInputSource) Rumble is supported on 'Xbox 360 Controller' via gamecontroller [ 2.1034] Current version: v1.7.4217 [ 2.1034] Latest SHA: v1.7.4217 [ 2.1034] Last Checked SHA: v1.7.4117 [ 2.1034] No update needed. [ 4.5567] Opening CDVD... [ 4.5569] isoFile open ok: /Volumes/Bootcamp/Emulation/Sony - Playstation 2/Silent Hill 4 - The Room (USA) (En,Ja).iso [ 4.5569] Image type = DVD [ 4.5570] * CDVD Disk Open: DVD, Single layer or unknown: [ 4.5570] * * Track 1: Data (Mode 1) (1920864 sectors) [ 4.5572] Opening GS... [ 4.5794] Metal Graphics Driver Info: [ 4.5795] <MTLIGAccelDevice: 0x7fe30e916000> [ 4.5795] name = Intel(R) Iris(TM) Plus Graphics [ 4.5795] Texture Swizzle: Supported [ 4.5795] Unified Memory: Supported [ 4.5795] Framebuffer Fetch: Unsupported [ 4.5795] Primitive ID: Supported [ 4.5795] Shader Version: Metal 2.2 [ 4.5795] Max Texture Size: 16384 [ 4.5938] Opening SPU2... [ 4.5949] Initializing SndBuffer at sample rate of 48000... [ 4.6054] (Cubeb) Using normal 2 speaker stereo output. [ 4.6055] (Cubeb) Minimum latency: 2.67 ms (128 audio frames) [ 4.6136] Opening PAD... [ 4.6136] Opening DEV9... [ 4.6178] Opening USB... [ 4.6178] Opening FW... [ 4.6178] McdSlot 0 [File]: [is not memcard file] [ 4.6178] McdSlot 1 [File]: [is not memcard file] [ 4.6180] McdSlot 0: [Folder] /Users/erik/Library/Application Support/PCSX2/memcards/Memory Card Folder.ps2 [ 4.6180] (FolderMcd) Indexing slot 0 with filter "". [ 4.6202] EE/iR5900-32 Recompiler Reset [ 4.6787] Vsync is ON [ 4.7831] Bios Found: USA v01.60(07/02/2002) Console 20020207-164243 [ 4.7841] BIOS rom1 module not found, skipping... [ 4.7841] BIOS rom2 module not found, skipping... [ 4.8007] VM subsystems initialized in 244.32 ms [ 4.8022] [GameDB] Has not been initialized yet, initializing... [ 4.8270] [GameDB] 11425 games on record (loaded in 24.87ms) [ 4.8270] [GameDB] Searching for '20020207-164243' in GameDB [ 4.8270] [GameDB] Could not find '20020207-164243' in GameDB [ 4.8271] McdSlot 0: [Folder] /Users/erik/Library/Application Support/PCSX2/memcards/Memory Card Folder.ps2 [ 4.8272] (FolderMcd) Indexing slot 0 with filter "20020207-164243". [ 4.8282] Game Changed: [ 4.8282] Name: [ 4.8282] Serial: 20020207-164243 [ 4.8282] CRC: 00000000 [ 4.8282] Applying settings... [ 4.8284] [GameDB] Searching for '20020207-164243' in GameDB [ 4.8284] [GameDB] Could not find '20020207-164243' in GameDB [ 5.0047] (SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLUS_208.73;1 [ 5.0047] (SYSTEM.CNF) Software version = 1.00 [ 5.0047] (SYSTEM.CNF) Disc region type = NTSC [ 5.0156] ELF (cdrom0:\SLUS_208.73;1) Game CRC = 0x3919136D, EntryPoint = 0x00100008 [ 5.0158] (SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLUS_208.73;1 [ 5.0159] (SYSTEM.CNF) Software version = 1.00 [ 5.0159] (SYSTEM.CNF) Disc region type = NTSC [ 6.7069] Elf entry point @ 0x00100008 about to get recompiled. Load patches first. [ 6.7069] [GameDB] Searching for 'slus-20873' in GameDB [ 6.7069] [GameDB] Found 'slus-20873' in GameDB [ 6.7069] [GameDB] Searching for patch with CRC '3919136D' [ 6.7069] [GameDB] No CRC-specific patch or default patch found [ 6.7071] Not found Cheats file: /Users/erik/Library/Application Support/PCSX2/cheats/3919136D.pnach [ 6.7071] Overall 0 Cheats loaded [ 6.7072] Overall 0 Widescreen hacks loaded [ 6.7359] Loading patch '3919136D.pnach' from archive. [ 6.7359] comment: Widescreen Hack [ 6.7372] (Wide Screen Cheats DB) Patches Loaded: 25 [ 6.7374] Overall 0 No-interlacing patches loaded [ 6.7388] (No-Interlacing Cheats DB) Patches Loaded: 0 [ 6.7388] OSD [LoadPatches]: 25 widescreen patches are active. [ 6.7391] [GameDB] Searching for 'slus-20873' in GameDB [ 6.7391] [GameDB] Found 'slus-20873' in GameDB [ 6.7392] McdSlot 0: [Folder] /Users/erik/Library/Application Support/PCSX2/memcards/Memory Card Folder.ps2 [ 6.7392] (FolderMcd) Indexing slot 0 with filter "SLUS-20873". [ 6.7423] Game Changed: [ 6.7423] Name: Silent Hill 4 - The Room [ 6.7423] Serial: SLUS-20873 [ 6.7423] CRC: 3919136D [ 6.7423] Loading game settings from '/Users/erik/Library/Application Support/PCSX2/gamesettings/SLUS-20873_3919136D.ini'... [ 6.7423] Applying settings... [ 6.7429] [GameDB] Searching for 'slus-20873' in GameDB [ 6.7429] [GameDB] Found 'slus-20873' in GameDB [ 6.7429] (GameDB) Setting Speedhack 'mvuFlag' to [mode=0] [ 6.7429] [GameDB] Enabled GS Hardware Fix: halfPixelOffset to [mode=1] [ 6.7429] Updating CPU configuration... [ 6.7774] Updating GS configuration... [ 6.7775] Vsync is ON [ 6.7779] Add 2 seconds play time to 20020207-164243 -> now 26 [ 6.7960] Hash for 'SLUS_208.73' (2924904 bytes, 2924904 bytes hashed): f5369ee15ecc3ea96451fbffa958186a [ 6.8469] EE/iR5900-32 Recompiler Reset [ 7.0564] Server returned GameID 1336 [ 7.4214] Game Title: Silent Hill 4: The Room [ 7.4214] Achievements: 66 [ 7.4214] Leaderboards: 0 [ 8.4006] Playing game updated to 1336 (Silent Hill 4: The Room) [ 9.2111] (UpdateVSyncRate) Mode Changed to NTSC. [ 11.4035] (VMManager) Pausing... [ 14.0604] (VMManager) Resuming... [ 49.0686] (VMManager) Pausing... [ 54.3885] Loading game settings from '/Users/erik/Library/Application Support/PCSX2/gamesettings/SLUS-20873_3919136D.ini'... [ 54.3887] Applying settings... [ 54.3896] [GameDB] Searching for 'slus-20873' in GameDB [ 54.3896] [GameDB] Found 'slus-20873' in GameDB [ 54.3896] (GameDB) Setting Speedhack 'mvuFlag' to [mode=0] [ 54.3896] [GameDB] Enabled GS Hardware Fix: halfPixelOffset to [mode=1] [ 54.3896] Updating GS configuration... [ 54.4024] Vsync is ON [ 54.4024] Reopening GS with new display [ 54.4453] No GPU requested, using first (Intel(R) Iris(TM) Plus Graphics) [ 54.4458] 4 vulkan queue families [ 54.4477] VK_EXT_provoking_vertex is NOT supported [ 54.4477] VK_EXT_line_rasterization is NOT supported [ 54.4477] VK_EXT_calibrated_timestamps is NOT supported [ 54.4477] VK_ARM_rasterization_order_attachment_access is NOT supported [ 54.5536] Read 230 entries from '/Users/erik/Library/Application Support/PCSX2/cache/vulkan_shaders.idx' [ 54.6050] Vulkan Graphics Driver Info: [ 54.6050] Driver 0.2.2010 [ 54.6050] Vulkan 1.2.239 [ 54.6050] Conformance Version 0.0.0.0 [ 54.6050] 1.2.2 [ 54.6050] MoltenVK [ 54.6050] Intel(R) Iris(TM) Plus Graphics [ 54.6050] VK_EXT_line_rasterization or the BRESENHAM mode is not supported, this may cause rendering inaccuracies. [ 57.2847] (VMManager) Resuming... [ 90.3068] (VMManager) Pausing... [ 96.2192] Loading game settings from '/Users/erik/Library/Application Support/PCSX2/gamesettings/SLUS-20873_3919136D.ini'... [ 96.2193] Applying settings... [ 96.2205] [GameDB] Searching for 'slus-20873' in GameDB [ 96.2205] [GameDB] Found 'slus-20873' in GameDB [ 96.2206] (GameDB) Setting Speedhack 'mvuFlag' to [mode=0] [ 96.2206] [GameDB] Enabled GS Hardware Fix: halfPixelOffset to [mode=1] [ 96.2206] Updating GS configuration... [ 96.2271] Vsync is ON [ 96.2272] Reopening GS with new display [ 96.2379] Writing 735005 bytes to '/Users/erik/Library/Application Support/PCSX2/cache/vulkan_pipelines.bin' [ 96.3320] Metal Graphics Driver Info: [ 96.3321] <MTLIGAccelDevice: 0x7fe30e916000> [ 96.3321] name = Intel(R) Iris(TM) Plus Graphics [ 96.3321] Texture Swizzle: Supported [ 96.3321] Unified Memory: Supported [ 96.3321] Framebuffer Fetch: Unsupported [ 96.3321] Primitive ID: Supported [ 96.3321] Shader Version: Metal 2.2 [ 96.3321] Max Texture Size: 16384 [ 99.5396] (VMManager) Resuming... [ 99.6663] Failed to create pipeline HW Render 1a.0.40000020440102.f1: Compiler encountered an internal error

bloedmage avatar Mar 12 '23 11:03 bloedmage

can you make a GS dump in VK of that scene which doesn't work in metal, then upload it here please?

refractionpcsx2 avatar Mar 12 '23 15:03 refractionpcsx2

FWIW I can't replicate this using the latest release on an M1 using Rosetta, Ventura 13.2.1.

It could be an Intel or Catalina thing.

shinra-electric avatar Mar 12 '23 20:03 shinra-electric

the solution may very well be "Update your OS"

refractionpcsx2 avatar Mar 12 '23 20:03 refractionpcsx2

Tested on Intel with iGPU (UHD 630), able to reproduce on macOS Catalina (10.15.7), unable to reproduce on macOS Ventura (13.4). GS dump attached, taken from (and double checked on) Catalina where it exhibits the bad behavior, but this GS dump behaves normally/as expected on Ventura.

Additionally, on Catalina when using the Metal renderer, if you switch to Vulkan and then back to Metal the whole emulator locks up for about 10-15 seconds before displaying anything again. This behavior exists both in game as well as with the GS dump.

gsdump.zip

DigitalMajestic avatar Jun 02 '23 00:06 DigitalMajestic

When the compiler backend ICEs, macOS usually retries it once or twice to make absolutely sure it's really broken, which is probably what causes the lockup

Anyways, for future reference, HW Render 1a.0.40000020440102.f1 is the shader key in hex, so it should be possible to map that back to what shader we're trying to compile. Since we use specialization constants instead of text splicing for Metal, that's all you're going to get, as the shader is always the same piece of text no matter what (the one in the repo). (Yeah it would be nice to have something to do this automatically, but for now we can do it manually...)

1a → VSExpand::Point, point_size=1 iip=0 tme=1 fst=0

Going to make a random guess and say that maybe we shouldn't use point_size=1 when we're drawing triangles (VSExpand::Point means "expand points to triangles")?

Edit: I wonder if this is the same thing that's breaking older Nvidia drivers...

TellowKrinkle avatar Jun 02 '23 01:06 TellowKrinkle

Never mind, I forgot Metal used its own VS selector That's VSExpand::Sprite, fst = 1, which seems a bit more normal

Here's the PS selector:

(GSHWDrawConfig::PSSelector) $1 = {
   = {
     = {
      aem_fmt = 0x00000002
      pal_fmt = 0x00000000
      dfmt = 0x00000000
      depth_fmt = 0x00000000
      aem = 0x00000001
      fba = 0x00000000
      fog = 0x00000000
      iip = 0x00000000
      date = 0x00000000
      atst = 0x00000000
      fst = 0x00000001
      tfx = 0x00000000
      tcc = 0x00000001
      wms = 0x00000000
      wmt = 0x00000000
      adjs = 0x00000000
      adjt = 0x00000000
      ltf = 0x00000001
      shuffle = 0x00000000
      real16src = 0x00000000
      read_ba = 0x00000000
      write_rg = 0x00000000
      fbmask = 0x00000000
      blend_a = 0x00000000
      blend_b = 0x00000000
      blend_c = 0x00000000
      blend_d = 0x00000000
      fixed_one_a = 0x00000000
      blend_hw = 0x00000000
      a_masked = 0x00000000
      hdr = 0x00000000
      colclip = 0x00000000
      blend_mix = 0x00000000
      round_inv = 0x00000000
      pabe = 0x00000000
      no_color = 0x00000000
      no_color1 = 0x00000001
      no_ablend = 0x00000000
      only_alpha = 0x00000000
      channel = 0x00000000
      dither = 0x00000000
      zclamp = 0x00000000
      tcoffsethack = 0x00000000
      urban_chaos_hle = 0x00000000
      tales_of_abyss_hle = 0x00000000
      tex_is_fb = 0x00000000
      automatic_lod = 0x00000000
      manual_lod = 0x00000000
      point_sampler = 0x00000000
      region_rect = 0x00000000
      scanmsk = 0x00000000
    }
     = (key_lo = 0x0040000020440102, key_hi = 0x00000000)
  }
}

Extras:

(PipelineSelectorExtrasMTL) $2 = {
   = {
     = {
      rt = 0x01
      writemask = 0x0f
      src_factor = 0x00
      dst_factor = 0x00
      blend_op = 0x00
      blend_enable = 0x00
      has_depth = 0x00
      has_stencil = 0x00
    }
    _key = "\xf1"
  }
}

TellowKrinkle avatar Jun 02 '23 02:06 TellowKrinkle

@DigitalMajestic can you run this on the computer that breaks? PCSX2CompileTest.zip

It takes as its argument the .metallib file that's in PCSX2, try it with each of the three (default.metallib, Metal22.metallib, Metal23.metallib)

Edit: Oops, if yours doesn't contain the line setFnConstantB(fn_constants, false, GSMTLConstantIndex_VS_POINT_SIZE);, download the updated version and try again

Edit: for anyone following along, I received the results via Discord:

Testing Intel(R) UHD Graphics 630...
Pipeline expand=0 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=1 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=2 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=3 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=0 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=1 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=2 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=3 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=0 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=1 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=2 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=3 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=0 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=1 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=2 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=3 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=0 failed: Compiler encountered an internal error
Pipeline expand=0 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=1 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=2 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=3 fst=0 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=0 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=1 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=2 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=3 fst=1 aem_fmt=1 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=0 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=1 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=2 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=3 fst=0 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=0 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=1 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=2 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error
Pipeline expand=3 fst=1 aem_fmt=2 aem=1 tcc=1 ltf=1 failed: Compiler encountered an internal error

TellowKrinkle avatar Jun 02 '23 02:06 TellowKrinkle

Side note, even though we are fixing this, you should really update your computer macOS 11 brings fbfetch support, which will make a number of games run much faster on that Intel GPU

TellowKrinkle avatar Jun 02 '23 03:06 TellowKrinkle