On Sat Apr 22 15:46:22 2023 +0000, Nikolay Sivov wrote:
I don't know if that's an optimization effect, but code in your example produces zero output unconditionally:
ps_4_0 dcl_output o0.xyzw mov o0.xyzw, l(0,0,0,0) ret
I don't know how this works exactly, but maybe constant arguments produce 0 derivatives, and using expression that depends on certain semantics generates actual instructions.
I think you're right; I changed the test to use VPOS and got a better result:
``` uniform float f;
float4 main(float4 pos : SV_POSITION) : sv_target { float x = ddx(pos.x); float y = ddy(pos.y); return float4(x, y, 1, 1); } ```
``` ps_4_0 dcl_input_ps_siv linear noperspective v0.xy, position dcl_output o0.xyzw deriv_rtx o0.x, v0.x deriv_rty o0.y, v0.y mov o0.zw, l(0,0,1.000000,1.000000) ret ```