Skip to content

Draft: vkd3d-shader/hlsl: Allocate temporary registers for constants only when necessary in SM1.

Shaun Ren requested to merge shaunren/vkd3d:sm1-const-no-temp-regs into master

For the following,

float4 x;
float4 main() : sv_target
{
    return x * 3 + 2;
}

With this MR, it compiles to:

ps_3_0
def c1 = 3.00000000e+00, 3.00000000e+00, 3.00000000e+00, 3.00000000e+00
def c2 = 2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00
mov r0.xyzw, c0.xyzw
mul r0.xyzw, r0.xyzw, c1.xyzw
add r0.xyzw, r0.xyzw, c2.xyzw
mov oC0.xyzw, r0.xyzw

Without, it compiles to:

ps_3_0
def c1 = 3.00000000e+00, 3.00000000e+00, 3.00000000e+00, 3.00000000e+00
def c2 = 2.00000000e+00, 2.00000000e+00, 2.00000000e+00, 2.00000000e+00
mov r0.xyzw, c0.xyzw
mov r1.xyzw, c1.xyzw
mul r0.xyzw, r0.xyzw, r1.xyzw
mov r1.xyzw, c2.xyzw
add r0.xyzw, r0.xyzw, r1.xyzw
mov oC0.xyzw, r0.xyzw
Edited by Shaun Ren

Merge request reports

Loading