vkd3d-shader/msl: Implement support for VKD3DSPR_UNDEF registers.

MSL doesn't seem to have any special handling for undefined values,
differently from SPIR-V. Thus we just emit zeros.

UNDEF registers are sometimes created by the DXIL parser,
for example in sm6_parser_emit_composite_construct().
This commit is contained in:
Giovanni Mascellani
2025-10-20 22:04:46 +02:00
committed by Henri Verbeet
parent eaabd2ffd7
commit cc1db404b0
Notes: Henri Verbeet 2025-10-30 20:00:07 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1757
10 changed files with 125 additions and 135 deletions

View File

@@ -619,9 +619,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
draw quad
probe (0, 0) f32(1.0, 1.0, 1.0, 1.0)
% Samplers cannot have packoffset(), unless register() is also specified, or they are not used.
% Note: In SM1 the rules are different: packoffset() is allowed for samplers, but they cannot be
@@ -850,8 +849,8 @@ uniform 4 float4 4.0 5.0 6.0 7.0
uniform 8 float4 8.0 9.0 10.0 11.0
uniform 12 float4 12.0 13.0 14.0 15.0
uniform 16 float4 16.0 17.0 18.0 19.0
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (124.0, 135.0, 146.0, 150.5)
draw quad
probe (0, 0) f32(124.0, 135.0, 146.0, 150.5)
[require]
shader model >= 5.1

View File

@@ -25,9 +25,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.2, 0.2, 0.2, 0.1)
draw quad
probe (0, 0) f32(0.2, 0.2, 0.2, 0.1)
[pixel shader]
Texture2D tex;
@@ -48,9 +47,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (31.1, 41.1, 51.1, 61.1) 1
draw quad
probe (0, 0) f32(31.1, 41.1, 51.1, 61.1) 1
[pixel shader]
Texture2D tex1;

View File

@@ -22,11 +22,11 @@ float4 main() : sv_target
[test]
uniform 0 uint 0
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 0.0, 1.0, 0.0)
draw quad
probe (0, 0) f32(1.0, 0.0, 1.0, 0.0)
uniform 0 uint 1
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.0, 0.0, 1.0, 0.0)
draw quad
probe (0, 0) f32(0.0, 0.0, 1.0, 0.0)
[pixel shader fail]
sampler s;
@@ -47,5 +47,5 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 0.0, 1.0, 0.0)
draw quad
probe (0, 0) f32(1.0, 0.0, 1.0, 0.0)

View File

@@ -73,12 +73,11 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8)
probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1)
probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
draw quad
probe (0, 0) f32(0.1, 0.2, 0.3, 0.4)
probe (1, 0) f32(0.5, 0.7, 0.6, 0.8)
probe (0, 1) f32(0.6, 0.5, 0.2, 0.1)
probe (1, 1) f32(0.8, 0.0, 0.7, 1.0)
[srv 0]
size (2d, 1, 1)
@@ -111,9 +110,8 @@ float4 main() : sv_target
}
[test]
todo(mvk & sm>=6 | msl & sm>=6) draw quad
probe (0, 0) rgba (312, 312, 312, 111)
todo(mvk & sm>=6) draw quad
probe (0, 0) f32(312, 312, 312, 111)
[pixel shader]
Texture2D tex1;
@@ -134,9 +132,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (2132, 2132, 2132, 1111)
draw quad
probe (0, 0) f32(2132, 2132, 2132, 1111)
[pixel shader fail(sm<6) todo(sm>=5.1)]
Texture2D tex[3];

View File

@@ -24,11 +24,10 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
todo(sm<6) draw quad
% sm6 seems to ignore profile qualifiers entirely.
if(sm>=6) probe (0,0) rgba (1, 1, 1, 99)
if(sm<6) probe (0,0) rgba (0, 0, 0, 99)
if(sm>=6) probe (0,0) f32(1, 1, 1, 99)
if(sm<6) probe (0,0) f32(0, 0, 0, 99)
[pixel shader todo]
Texture2D tex1 : register(cs, t1);
@@ -39,10 +38,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0,0) rgba (1, 1, 1, 99)
if(sm<6) probe (0,0) rgba (0, 0, 0, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0,0) f32(1, 1, 1, 99)
if(sm<6) probe (0,0) f32(0, 0, 0, 99)
[pixel shader todo]
Texture2D tex1 : register(ps, t1);
@@ -53,9 +51,8 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
probe (0, 0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
probe (0, 0) f32(1, 1, 1, 99)
[pixel shader fail todo]
Texture2D tex1 : register(PS, t1);
@@ -93,9 +90,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1, 1, 1, 99)
draw quad
probe (0, 0) f32(1, 1, 1, 99)
[pixel shader todo]
Texture2D tex1 : register(ps_4_0, t1);
@@ -106,9 +102,8 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
probe (0, 0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
probe (0, 0) f32(1, 1, 1, 99)
[pixel shader fail]
Texture2D tex1 : register(ps.4.0, t1);
@@ -128,10 +123,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0,0) rgba (1, 1, 1, 99)
if(sm<6) probe (0,0) rgba (0, 0, 0, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0,0) f32(1, 1, 1, 99)
if(sm<6) probe (0,0) f32(0, 0, 0, 99)
[pixel shader todo]
Texture2D tex1 : register(ps_4_1, t1) : register(ps_4_0, t2);
@@ -142,8 +136,8 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
probe (0, 0) rgba (2, 2, 2, 99)
todo(sm<6) draw quad
probe (0, 0) f32(2, 2, 2, 99)
% The documentation explicitly gives this case as an example, implying that a
% more specific profile takes precedence over a less specific one. It doesn't.
@@ -163,10 +157,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0,0) rgba (2, 2, 2, 99)
if(sm<6) probe (0,0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0,0) f32(2, 2, 2, 99)
if(sm<6) probe (0,0) f32(1, 1, 1, 99)
[pixel shader fail(sm<4.1) todo]
Texture2D tex1 : register(ps, t1) : register(ps_4_0, t2);
@@ -177,9 +170,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (2, 2, 2, 99)
draw quad
probe (0, 0) f32(2, 2, 2, 99)
[pixel shader fail(sm<4.1) todo]
Texture2D tex1 : register(ps_4_0, t1) : register(ps, t2);
@@ -190,9 +182,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (2, 2, 2, 99)
draw quad
probe (0, 0) f32(2, 2, 2, 99)
[pixel shader fail(sm<6) todo]
Texture2D tex1 : register(ps_6_0, t1) : register(ps, t2);
@@ -203,9 +194,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (2, 2, 2, 99)
draw quad
probe (0, 0) f32(2, 2, 2, 99)
[pixel shader fail(sm<4.1 | sm>=6) todo]
Texture2D tex1 : register(ps_4_0, t1) : register(t2);
@@ -257,8 +247,8 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
probe (0, 0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
probe (0, 0) f32(1, 1, 1, 99)
% Bracket exprs should still parse correctly.
@@ -271,9 +261,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0, 0) rgba(0, 0, 0, 99)
if(sm<6) probe (0, 0) rgba(1, 1, 1, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0, 0) f32(0, 0, 0, 99)
if(sm<6) probe (0, 0) f32(1, 1, 1, 99)
% This works, though the bind point is ignored.

View File

@@ -34,9 +34,8 @@ float4 main() : sv_target
}
[test]
todo(mvk & sm>=6 | msl & sm>=6) draw quad
probe (0, 0) rgba (41.0, 41.0, 41.0, 1089.0)
todo(mvk & sm>=6) draw quad
probe (0, 0) f32(41.0, 41.0, 41.0, 1089.0)
% If no component in a texture array is used, and it doesn't have a register reservation, no
% register is reserved.
@@ -50,9 +49,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.0, 0.0, 0.0, 99.0)
draw quad
probe (0, 0) f32(0.0, 0.0, 0.0, 99.0)
% Register reservations force to reserve all the resource registers. Even if unused.
[pixel shader]
@@ -65,9 +63,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 99.0)
draw quad
probe (0, 0) f32(1.0, 1.0, 1.0, 99.0)
% Register reservation with incorrect register type.
[pixel shader]
@@ -91,8 +88,8 @@ probe (0, 0) rgba (0.0, 0.0, 0.0, 99.0)
shader model >= 6.0
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 99.0)
draw quad
probe (0, 0) f32(1.0, 1.0, 1.0, 99.0)
[require]
shader model >= 4.0
@@ -108,10 +105,9 @@ float4 main() : sv_target
return tex.Load(int3(0, 0, 0));
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.0, 0.0, 0.0, 99.0)
draw quad
probe (0, 0) f32(0.0, 0.0, 0.0, 99.0)
[pixel shader]
Texture2D unused[2][2] : register(t0);
@@ -123,9 +119,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (4.0, 4.0, 4.0, 99.0)
draw quad
probe (0, 0) f32(4.0, 4.0, 4.0, 99.0)
% Overlapping reservations, both overlapping objects are unused.
[pixel shader]
@@ -139,9 +134,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 99.0)
draw quad
probe (0, 0) f32(1.0, 1.0, 1.0, 99.0)
% Overlapping reservations
[pixel shader]
@@ -154,9 +148,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (2.0, 2.0, 2.0, 99.0)
draw quad
probe (0, 0) f32(2.0, 2.0, 2.0, 99.0)
[pixel shader]
Texture2D tex1 : register(t2);
@@ -168,9 +161,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (2.0, 2.0, 2.0, 99.0)
draw quad
probe (0, 0) f32(2.0, 2.0, 2.0, 99.0)
[require]
shader model >= 5.0
@@ -241,5 +233,5 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 99.0)
draw quad
probe (0, 0) f32(1.0, 1.0, 1.0, 99.0)

View File

@@ -26,8 +26,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (1, 1, 1, 99)
draw quad
probe (0, 0) f32(1, 1, 1, 99)
% Bracket syntax for registers. Ignored in SM>=6.
[pixel shader]
@@ -39,9 +39,9 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
if(sm>=6) probe (0, 0) rgba (0, 0, 0, 99)
if(sm<6) probe (0, 0) rgba (1, 1, 1, 99)
draw quad
if(sm>=6) probe (0, 0) f32(0, 0, 0, 99)
if(sm<6) probe (0, 0) f32(1, 1, 1, 99)
[pixel shader fail(sm>=6)]
Texture2D tex1 : register(t1, sPaCe0);
@@ -74,9 +74,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0, 0, 0, 99)
draw quad
probe (0, 0) f32(0, 0, 0, 99)
[pixel shader fail(sm<6)]
Texture2D tex1 : register(space0);
@@ -87,9 +86,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0, 0, 0, 99)
draw quad
probe (0, 0) f32(0, 0, 0, 99)
% Specifying a profile is just broken. The first reservation (or, with sm6, the
% last) is taken regardless of whether it actually matches the current profile.
@@ -103,9 +101,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0,0) rgba (2, 2, 2, 99)
if(sm<6) probe (0,0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0,0) f32(2, 2, 2, 99)
if(sm<6) probe (0,0) f32(1, 1, 1, 99)
% Same as above, but with bracket exprs, which are ignored in SM>=6.
@@ -118,9 +116,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0, 0) rgba (0, 0, 0, 99)
if(sm<6) probe (0, 0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0, 0) f32(0, 0, 0, 99)
if(sm<6) probe (0, 0) f32(1, 1, 1, 99)
% This actually inheres to 5.1+; it doesn't matter whether "space" is specified.
@@ -133,10 +131,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0,0) rgba (2, 2, 2, 99)
if(sm<6) probe (0,0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0,0) f32(2, 2, 2, 99)
if(sm<6) probe (0,0) f32(1, 1, 1, 99)
% It's still illegal to specify multiple contradictory reservations with the
% same profile...
@@ -161,10 +158,9 @@ float4 main() : sv_target
}
[test]
todo(sm<6 | msl) draw quad
if(sm>=6) probe (0,0) rgba (2, 2, 2, 99)
if(sm<6) probe (0,0) rgba (1, 1, 1, 99)
todo(sm<6) draw quad
if(sm>=6) probe (0,0) f32(2, 2, 2, 99)
if(sm<6) probe (0,0) f32(1, 1, 1, 99)
% Test conflicts.

View File

@@ -48,8 +48,8 @@ float4 main() : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.8, -3.0, 4294967295.0, 123.0)
draw quad
probe (0, 0) f32(0.8, -3.0, 4294967295.0, 123.0)
% lowercase 'texture2D'

View File

@@ -15,11 +15,11 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
probe (1, 0) rgba (0.5, 0.7, 0.6, 0.8)
probe (0, 1) rgba (0.6, 0.5, 0.2, 0.1)
probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
draw quad
probe (0, 0) f32(0.1, 0.2, 0.3, 0.4)
probe (1, 0) f32(0.5, 0.7, 0.6, 0.8)
probe (0, 1) f32(0.6, 0.5, 0.2, 0.1)
probe (1, 1) f32(0.8, 0.0, 0.7, 1.0)
[pixel shader]
Texture2D t;
@@ -30,11 +30,11 @@ float4 main(float4 pos : sv_position) : sv_target
}
[test]
todo(msl & sm>=6) draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
probe (1, 0) rgba (0.6, 0.5, 0.2, 0.1)
probe (0, 1) rgba (0.5, 0.7, 0.6, 0.8)
probe (1, 1) rgba (0.8, 0.0, 0.7, 1.0)
draw quad
probe (0, 0) f32(0.1, 0.2, 0.3, 0.4)
probe (1, 0) f32(0.6, 0.5, 0.2, 0.1)
probe (0, 1) f32(0.5, 0.7, 0.6, 0.8)
probe (1, 1) f32(0.8, 0.0, 0.7, 1.0)
[pixel shader]
static const int size = 2;