GPUOpen-LibrariesAndSDKs / AGS_SDK

AMD GPU Services (AGS) library and samples
MIT License
244 stars 42 forks source link

d3d11 unreliable behavior with ReadFirstLane--results appear to depend on random compiler optimizations #29

Open Niadb opened 5 years ago

Niadb commented 5 years ago

I'm seeing very unreliable behavior when trying to use AmdDxExtShaderIntrinsics_ReadfirstlaneU

If it works or not appears to depend on essentially random changes to the shader.

This is very unfortunate as when it does work, the performance benefit compared to not using ReadfirstLane is significant--45fps vs ~60fps.

When it fails, the result of ReadfirstLaneU seems very random, almost like it isn't reading valid data, and whatever it is reading doesn't seem to be something that was contained in any* of the lanes..

At a guess I'd say this is related to the UAV "hack" used to bypass the D3D shader compiler, perhaps it is sometimes optimizing the output such that AGS can't find its hooks?

The shader in question is very large and a number of other AGS features used.

gareththomasamd commented 5 years ago

Hi, are you definitely using /Ges (enable strictness) and not using /Od (skip debug opts)?

Niadb commented 5 years ago

hi gareth, I was compiling with:

shader_compile_flags = D3D10_SHADER_OPTIMIZATION_LEVEL3 ;

I tried adding the strictness flag:

shader_compile_flags = D3D10_SHADER_OPTIMIZATION_LEVEL3 | D3DCOMPILE_ENABLE_STRICTNESS;

But it doesn't seem to change the result, ReadFirstLane still produces noise

Niadb commented 5 years ago

I'll try and provide some more info in case it helps:

If there was a way to get the generated assembly from the driver, instead of having to use awkward tools that may not even produce the same result as the game, that would probably be very useful.