ValveSoftware / Proton

Compatibility tool for Steam Play based on Wine and additional components
Other
24.53k stars 1.07k forks source link

東方聖戦影 ~ Forlorn Souls of Wicked Past Demo (3138390) #8190

Open yoshiweegee opened 3 weeks ago

yoshiweegee commented 3 weeks ago

Compatibility Report

System Information

I confirm:

steam-3138390.log

Symptoms

Shortly after the game window becomes visible and adjusts its dimensions, an error dialogue appears with a report. It sometimes appears behind the game window. Clicking OK allows the game to exit gracefully. The config program is unaffected.

On tested Proton versions from 9.0-3 to current bleeding-edge, the message is:

RenderShaderLibrary: Shader compile failed. [_HLSL_INTERNAL_RENDER2D]
        E_INVALIDARG
        E5020: The 'fx_2_0' target profile is only compatible with the 'fx' target type.

On tested earlier Proton versions, the message is:

RenderShaderLibrary: Shader compile failed. [_HLSL_INTERNAL_RENDER2D]
        E_FAIL
        <anonymous>:1:62: E5000: syntax error, unexpected ':', expecting ';' or ','
\

Both messages refer to the _HLSL_INTERNAL_RENDER2D shader defined within the game engine, Touhou Danmakufu ph3sx v1.33a-pre Touhou Danmakufu ph3sx zlabel v1.33a-pre (master). The shader defined for v1.33a-pre can be found here.

Reproduction

  1. Start the game (not the config program)
  2. Wait for the window to become visible and adjust its dimensions
  3. Observe the error dialogue. It may be hidden behind the game window.
yoshiweegee commented 1 week ago

Dug through the functions and found where the shader compilation failure is occurring in the latest versions.

It seems that because the Wine repository is using vkd3d 1.10 where VKD3D_SHADER_TARGET_FX didn't exist yet, there's a mismatch between what Proton's Wine and vkd3d expect for compiling D3D effects, resulting in compile_info.target_type being set improperly.

yoshiweegee commented 1 week ago

Tested with the only changes being vkd3d being version 1.10 and commit e527d7c (the commit right before adding VKD3D_SHADER_TARGET_FX). The error is exactly the same as when testing with Proton versions up to 8.0-5, regarding an unexpected ':'.

yoshiweegee commented 1 week ago

Dug through vkd3d and found that the other error is a bug in its HLSL lexer.

This bug has already been fixed in Wine's GitLab repository. These changes should be mirrored ASAP so that Proton bleeding-edge can benefit from them.


The following is a technical explanation of why the bug currently affects this game.

Microsoft's documentation about Direct3D HLSL variable syntax indicates it is: [Storage_Class] [Type_Modifier] Type Name[Index] [: Semantic] [: Packoffset] [: Register]; [Annotations] [= Initial_Value] Of note are the parts for Semantic, Packoffset, and Register, known as the attributes. Nowhere on this page is it suggested that multiple attributes can't be used.

However, vkd3d's lexer, when encountering a variable declaration, deduces the following in libs/vkd3d-shader/hlsl.y:

None of the options for colon_attribute account for the possibility of more attributes, leaving the lexer to expect either a colon for variables_def_typed ',' variable_def to complete variables_def_typed, or a semicolon for variables_def_typed ';' to complete declaration.

This explains the error message for this game, since the _HLSL_INTERNAL_RENDER2D shader contains this statement: float4x4 g_mWorld : WORLD : register(c0); The lexer for vkd3d is expecting a semicolon or comma after the semantic attribute WORLD, hence the error: syntax error, unexpected ':', expecting ';' or ','.

yoshiweegee commented 1 week ago

It seems that because the Wine repository is using vkd3d 1.10 where VKD3D_SHADER_TARGET_FX didn't exist yet, there's a mismatch between what Proton's Wine and vkd3d expect for compiling D3D effects, resulting in compile_info.target_type being set improperly.

Similarly to vkd3d, Wine's GitLab repository has updated to vkd3d 1.13 (according to the commit messages, but config.h suggests it's still 1.12) _and properly uses VKD3D_SHADER_TARGET_FX._

yoshiweegee commented 1 week ago

I attempted to cherry-pick the relevant changes to get a successful run. My changes and findings in order:

alasky17 commented 1 week ago

@yoshiweegee Thank you for this information. Our plan is (and has been for a while) to regularly update the vkd3d submodule, but we do not yet have it automatically updating from the master branch on winehq as you've noticed. I would recommend filing any bugs for vkd3d failures like you find in the winehq bugzilla with the selected "product" vkd3d - https://bugs.winehq.org/enter_bug.cgi?product=vkd3d :)

yoshiweegee commented 6 days ago

I believe it's technically already been reported as Bug 37676. Per your advice, I'll refer to my findings here in a comment for that bug report soon.