On Thu Apr 27 02:11:11 2023 +0000, Francisco Casas wrote:
Hi! I got this dissasembly from your test (replacing `ddx = dd.xy;` and `ddy = dd.zw;`):
vkd3d:trace:hlsl_dump_function Function parameters: vkd3d:trace:hlsl_dump_function in float4 position : SV_POSITION0 vkd3d:trace:hlsl_dump_function 2: float4 | <input-SV_POSITION0> vkd3d:trace:hlsl_dump_function 3: float4 | dd vkd3d:trace:hlsl_dump_function 4: float | @2.x vkd3d:trace:hlsl_dump_function 5: float | 6.40000000e+02 vkd3d:trace:hlsl_dump_function 6: float | / (@4 @5 ) vkd3d:trace:hlsl_dump_function 7: | = (p.x @6) vkd3d:trace:hlsl_dump_function 8: float | @2.y vkd3d:trace:hlsl_dump_function 9: float | 4.80000000e+02 vkd3d:trace:hlsl_dump_function 10: float | / (@8 @9 ) vkd3d:trace:hlsl_dump_function 11: | = (p.y @10) vkd3d:trace:hlsl_dump_function 12: float2 | p vkd3d:trace:hlsl_dump_function 13: float2 | @3.xy vkd3d:trace:hlsl_dump_function 14: float2 | @3.zw vkd3d:trace:hlsl_dump_function 15: float4 | sample_grad(resource = t, sampler = s, coords = @12, ddx = @13, ddy = @14) vkd3d:trace:hlsl_dump_function 16: | = (<output-SV_Target0> @15)
Using FIXME()'s bombardment :tm: I realized that the assertion fails because the register for instruction 13 is not allocated. This register is not allocated because `compute_livenes_recurse` is failing to inform that instructions 13 and 14 are used by sample_grad. Every time you add new fields to an instruction node type, that refer to other instruction nodes (generally hlsl_src) you have to perform certain updates to functions:
- The clone_instr() in hlsl.c (well, actually one if its callees).
- The compute_liveness_recurse() function in hlsl_codegen.c. (this
causes the assertion failed in this case). If C had reflection we could get away with writing these functions in a way that doesn't require these updates.
I should also add the corresponding dump_instr() callee for completion, but I see you updated that one.