YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
21 stars 8 forks source link

Building Projects: Shader compilation shows benign errors when verbose compiler logging is enabled, would be better to prevent these #6088

Open DragoniteSpam opened 3 months ago

DragoniteSpam commented 3 months ago

Description

Some more elaborate shaders show compile errors in the optimization stage, while they didn't before.

Quite a lot of them can be seen in projects using spart, but it happens with a bunch of others - including some of the built-in SDF font shaders.

C:\ProgramData\GameMakerStudio2-Beta\Cache\runtimes\runtime-2024.600.0.581\bin\assetcompiler\Shaders\D3D11ShaderParser.exe -verbose -quiet -profile vs_auto -shader "F:\GameMaker\Temp\GMS2TEMP\vout.shader" -out "F:\GameMaker\AssetCache\GMS2CACHE\spart_321D13DA\spart\Default\Shader\HLSL11\Default_sh_smf_particle_vout.shdata" -name "Shader_sh_smf_particle"
Compiling Shader Shader_sh_smf_particle for vs_4_0_level_9_1 (optimised)
Compile Errors for Shader_sh_smf_particle compiling for vs_4_0_level_9_1 (optimised):
F:\GameMaker\Temp\GMS2TEMP\vout.shader(270,2-28): warning X3552: cannot map loop to shader target, target does not support breaks, forcing loop to unroll
F:\GameMaker\Temp\GMS2TEMP\vout.shader(270,2-28): error X3511: unable to unroll loop, loop does not appear to terminate in a timely manner (611 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number
Attempting Shader compilation of Shader_sh_smf_particle for vs_4_0_level_9_1 unoptimised due to errors in initial compile 
Compiling Shader Shader_sh_smf_particle for vs_4_0_level_9_3 (optimised)
Compile Errors for Shader_sh_smf_particle compiling for vs_4_0_level_9_3 (optimised):
F:\GameMaker\Temp\GMS2TEMP\vout.shader(569,14): error X5615: Compiled shader code uses too many instruction slots (693). Max. allowed by the target (vs_2_x) is 256.
Attempting Shader compilation of Shader_sh_smf_particle for vs_4_0_level_9_3 unoptimised due to errors in initial compile 
Compiling Shader Shader_sh_smf_particle for vs_4_0 (optimised)
Compiled with vs_4_0 (optimised)

Regardless of whether or not this is just about shader optimization (unrolling loops etc), seeing errors like this coming about from, for example, the SDF font shader that's included in every project is surely going to alarm quite a lot of people.

C:\ProgramData\GameMakerStudio2-Beta\Cache\runtimes\runtime-2024.600.0.581\bin\assetcompiler\Shaders\D3D11ShaderParser.exe -verbose -quiet -profile ps_auto -shader "F:\GameMaker\Temp\GMS2TEMP\fout.shader" -out "F:\GameMaker\AssetCache\GMS2CACHE\spart_321D13DA\spart\Default\Shader\HLSL11\Default___yy_sdf_effect_shader_fout.shdata" -name "Shader___yy_sdf_effect_shader"
Compiling Shader Shader___yy_sdf_effect_shader for ps_4_0_level_9_1 (optimised)
Compile Errors for Shader___yy_sdf_effect_shader compiling for ps_4_0_level_9_1 (optimised):
F:\GameMaker\Temp\GMS2TEMP\fout.shader(98,22-38): error X4532: cannot map expression to pixel shader instruction set
Attempting Shader compilation of Shader___yy_sdf_effect_shader for ps_4_0_level_9_1 unoptimised due to errors in initial compile

Steps To Reproduce

Run the sample project in a 600 beta, and then run it in a previous monthly where the errors don't appear

Which version of GameMaker are you reporting this issue for?

IDE v2024.600.0.563 Runtime v2024.600.0.581

Which operating system(s) are you seeing the problem on?

Windows 10.0.19045.0

Which platform(s) are you seeing the problem on?

Windows

592c1e8a-b647-45b5-907a-fc7ee80f29b2

DragoniteSpam commented 3 months ago

For those in the audience, the sample project is spart, which can be found here.

JonnoRobson commented 3 months ago

Are you able to check that verbose compiler output is enabled in both versions you're testing this issue in? The setting is under "File > Preferences > General Settings > Compiling > Show verbose compiler output". I'm currently testing with the latest BETA version and the stable April version and am getting the same shader compilation errors in both versions while I have verbose compiler output enabled. It would be helpful to establish that the issue definitely isn't related to changes in the BETA version.

The errors themselves are produced when testing if the shaders will compile using the "vs_4_0_level_9_1" and "vs_4_0_level_9_3" feature levels for compatibility with older versions of Direct3D. They are ultimately benign since all of the shaders are able to compile with the Direct3D 10 feature levels, but it may be useful to suppress the errors if not relevant to avoid reporting unnecessary errors.

DragoniteSpam commented 3 months ago

Interesting, I am. I wonder if I turned that on at some point to debug something else or something.

JonnoRobson commented 3 months ago

Thanks for the update. It appears that these errors have been present for a while and are only visible when verbose compiler output is enabled. As I previously said they are produced when attempting to compile shaders for different Direct3D feature levels and are ultimately benign since there are levels which most shaders successfully compile for. That being said I'll look into improving the messaging when compiling shaders to make the output more clear to users who want to run using verbose compiler output.