Skip to content

vkd3d-shader/hlsl: Add support for ddx(), ddy() intrinsics.

Ethan Lee requested to merge flibitijibibo/vkd3d:dsxdsy into master

SPIR-V already handled DSX/DSY, so only D3DBC/TPF needed new case blocks.

You'll notice that there's no test for this one - in addition to being a pretty straightforward translation for all possible formats, this feature uses the render target width/height and I wasn't sure if there was a good way to ensure that the test would always make sense.

Instead, I did the test manually, and it's what you'd expect (EDIT: Previously the test used a uniform which always optimized to 0, new test uses VPOS instead):

HLSL:

float4 main(float4 pos : sv_position) : sv_target
{
    float4 x = ddx(pos.x);
    float4 y = ddy(pos.y);
    return x + y;
}

D3DBC:

ps_3_0
dcl_position0 vPos
mov r0.xyzw, vPos.xyzw
mov r1.x, r0.x
dsx r1.x, r1.x
mov r0.x, r0.yxxx
dsy r0.x, r0.x
mov r1.xyzw, r1.x
mov r0.xyzw, r0.x
add r0.xyzw, r1.xyzw, r0.xyzw
mov oC0.xyzw, r0.xyzw

DXBC-TPF:

ps_4_0
dcl_input_ps_siv linear v0.xyzw, position
dcl_output o0.xyzw
dcl_temps 2
mov r0.xyzw, v0.xyzw
mov r1.x, r0.x
dsx r1.x, r1.x
mov r0.x, r0.yxxx
dsy r0.x, r0.x
mov r1.xyzw, r1.x
mov r0.xyzw, r0.x
add r0.xyzw, r1.xyzw, r0.xyzw
mov o0.xyzw, r0.xyzw
ret

Fixes https://bugs.winehq.org/show_bug.cgi?id=54827

Edited by Ethan Lee

Merge request reports

Loading