tests/shader_runner_metal: Implement draws.

This commit is contained in:
Feifan He 2024-11-04 18:54:30 +08:00 committed by Henri Verbeet
parent 14991f2e17
commit 1efc0ac740
Notes: Henri Verbeet 2024-11-20 15:00:07 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1243
20 changed files with 87 additions and 69 deletions

View File

@ -88,5 +88,5 @@ uniform 4 float 0.0
uniform 8 float 0.0
uniform 12 float 0.0
uniform 16 float 42.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (42, 42, 42, 42)

View File

@ -20,7 +20,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 123.0 -2.0 456 0.01
todo(msl) draw quad
draw quad
probe (320,240) rgba (123.0, -2.0, 456.0, 0.01)
[pixel shader]

View File

@ -13,7 +13,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader fail(sm>=6)]
@ -61,7 +61,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader fail(sm>=6)]
@ -83,7 +83,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader]
@ -97,7 +97,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader fail]
@ -150,7 +150,7 @@ uniform 0 float4 0.0 1.0 2.0 3.0
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
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.0, 2.0, 4.0, 8.0)
@ -171,7 +171,7 @@ float4 main() : sv_target
uniform 0 float4 0.0 1.0 2.0 3.0
uniform 4 float4 4.0 5.0 6.0 7.0
uniform 8 float4 8.0 9.0 10.0 11.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.0, 4.0, 8.0, 9.0)
@ -197,7 +197,7 @@ uniform 0 float4 0.0 1.0 2.0 3.0
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
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.0, 4.0, 5.0, 6.0)
@ -291,7 +291,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (2.0, 3.0, 2.0, 3.0)
@ -427,7 +427,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (3.0, 4.0, 3.0, 4.0)
@ -767,7 +767,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
uniform 4 float4 0.0 0.0 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader fail(sm<6)]

View File

@ -17,7 +17,7 @@ if(sm<4) uniform 8 float4 10 20 0 0
if(sm>=4) uniform 0 float4 10 20 0 0
if(sm>=4) uniform 4 float4 10 30 50 70
if(sm>=4) uniform 8 float4 20 40 60 80
todo(msl) draw quad
draw quad
probe (0, 0) rgba (10, 20, 50, 60)
@ -57,7 +57,7 @@ float4 main() : sv_target { return b; }
[test]
uniform 0 float4 10.0 20.0 30.0 40.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (10, 20, 30, 40)
@ -134,7 +134,7 @@ if(sm<4) uniform 8 float4 10 20 0 0
if(sm>=4) uniform 0 float4 10 20 0 0
if(sm>=4) uniform 4 float4 10 30 50 70
if(sm>=4) uniform 8 float4 20 40 60 80
todo(msl) draw quad
draw quad
probe (0, 0) rgba (10, 20, 50, 60)
@ -170,7 +170,7 @@ float4 main() : sv_target { return b; }
[test]
uniform 0 float4 10 20 30 40
todo(msl) draw quad
draw quad
probe (0, 0) rgba (10, 20, 30, 40)

View File

@ -8,7 +8,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 9.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (9.0, 9.0, 9.0, 9.0)
[pixel shader]
@ -21,7 +21,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader]
@ -49,7 +49,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
uniform 4 float4 5.0 6.0 7.0 8.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader]

View File

@ -40,7 +40,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (3.0, 3.0, 3.0, 3.0)
@ -78,7 +78,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (4.0, 4.0, 4.0, 4.0)

View File

@ -19,5 +19,5 @@ float4 main() : sv_target
[test]
uniform 0 float 10.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (10.0, 10.0, 10.0, 10.0)

View File

@ -40,7 +40,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
@ -61,7 +61,7 @@ uniform 0 float4 0.0 0.0 0.0 0.0
uniform 4 float4 0.0 0.0 0.0 0.0
uniform 8 float4 0.5 0.6 0.0 0.0
uniform 12 float4 0.7 0.8 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.5, 0.6, 0.7, 0.8)
@ -112,7 +112,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
@ -150,7 +150,7 @@ uniform 0 float4 0.3 0.4 0.0 0.0
uniform 4 float4 0.0 0.0 0.0 0.0
uniform 8 float4 0.0 0.0 0.0 0.0
uniform 12 float4 0.5 0.6 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.3, 0.4, 0.5, 0.6)
@ -174,7 +174,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
@ -202,7 +202,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.2 0.4 0.0 0.0
uniform 4 float4 0.3 0.5 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.2, 0.3, 0.4, 0.5)
@ -222,7 +222,7 @@ uniform 0 float4 0.3 0.0 0.0 0.0
uniform 4 float4 0.4 0.0 0.0 0.0
uniform 8 float4 0.0 0.5 0.0 0.0
uniform 12 float4 0.0 0.6 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.3, 0.4, 0.5, 0.6)
% Compiler options
@ -246,7 +246,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3
uniform 4 float4 0.2 0.6 1.0 1.4
uniform 8 float4 0.3 0.7 1.1 1.5
uniform 12 float4 0.4 0.8 1.2 1.6
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.2, 0.3, 0.6, 0.7) 1
[require]
@ -268,7 +268,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3
uniform 4 float4 0.2 0.6 1.0 1.4
uniform 8 float4 0.3 0.7 1.1 1.5
uniform 12 float4 0.4 0.8 1.2 1.6
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.2, 0.3, 0.6, 0.7) 1
[require]
@ -290,7 +290,7 @@ uniform 0 float4 0.1 0.5 0.9 1.3
uniform 4 float4 0.2 0.6 1.0 1.4
uniform 8 float4 0.3 0.7 1.1 1.5
uniform 12 float4 0.4 0.8 1.2 1.6
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.5, 0.9, 0.6, 1.0) 1
[require]
@ -318,7 +318,7 @@ uniform 16 float4 1.7 2.1 2.5 2.9
uniform 20 float4 1.8 2.2 2.6 3.0
uniform 24 float4 1.9 2.3 2.7 3.1
uniform 28 float4 2.0 2.4 2.8 3.2
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.3, 0.4, 2.5, 2.9) 1
[require]
@ -346,7 +346,7 @@ uniform 16 float4 1.7 2.1 2.5 2.9
uniform 20 float4 1.8 2.2 2.6 3.0
uniform 24 float4 1.9 2.3 2.7 3.1
uniform 28 float4 2.0 2.4 2.8 3.2
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.2, 1.6, 3.1, 3.2) 1
[require]
@ -366,5 +366,5 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.3, 0.2, 0.4) 1

View File

@ -11,7 +11,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.3 0.0 0.0
uniform 4 float4 0.2 0.4 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.3, 0.2, 0.4)
[pixel shader fail(sm<6)]

View File

@ -11,7 +11,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0
uniform 4 float4 5.0 6.0 7.0 8.0
uniform 8 float4 9.0 10.0 11.0 12.0
uniform 12 float4 13.0 14.0 15.0 16.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 10.0, 15.0)
[pixel shader]
@ -27,7 +27,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0
uniform 4 float4 5.0 6.0 7.0 8.0
uniform 8 float4 9.0 10.0 11.0 12.0
uniform 12 float4 13.0 14.0 15.0 16.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 10.0, 15.0)
[pixel shader]
@ -43,7 +43,7 @@ uniform 0 float4 1.0 2.0 3.0 4.0
uniform 4 float4 5.0 6.0 7.0 8.0
uniform 8 float4 9.0 10.0 11.0 12.0
uniform 12 float4 13.0 14.0 15.0 16.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 5.0, 7.0, 12.0)
[pixel shader]
@ -58,7 +58,7 @@ float4 main() : SV_TARGET
[test]
uniform 0 float4 1.0 2.0 3.0 0.0
uniform 4 float4 5.0 6.0 7.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 3.0, 6.0, 7.0)
[pixel shader]

View File

@ -21,5 +21,5 @@ uniform 8 float4 0.3 0.0 0.0 0.0
uniform 12 float4 0.4 0.0 0.0 0.0
uniform 16 float4 0.5 0.0 0.0 0.0
uniform 20 float4 0.6 0.0 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.4, 0.1, 0.6, 0.3)

View File

@ -9,7 +9,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.3 0.4
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
[pixel shader fail(sm>=6)]
@ -23,7 +23,7 @@ precise main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.3 0.4
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)
[pixel shader]
@ -37,5 +37,5 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.3 0.4
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.1, 0.2, 0.3, 0.4)

View File

@ -56,7 +56,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 0.1 0.2 0.3 0.4
uniform 4 float4 1.1 1.2 1.3 1.4
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.1, 1.4, 0.2, 0.3)
@ -75,7 +75,7 @@ uniform 4 float4 1.1 1.2 1.3 1.4
uniform 8 float4 2.1 2.2 2.3 2.4
uniform 12 float4 3.1 3.2 3.3 3.4
uniform 16 float4 4.1 4.2 4.3 4.4
todo(msl) draw quad
draw quad
probe (0, 0) rgba (4.1, 4.2, 1.3, 1.4)
@ -207,7 +207,7 @@ float4 main() : sv_target
[test]
uniform 0 float 100
uniform 4 float 101
todo(msl) draw quad
draw quad
probe (0, 0) rgba (100, 100, 100, 100)
@ -221,7 +221,7 @@ float4 main(uniform float a : register(c1)) : sv_target
[test]
uniform 0 float 100
uniform 4 float 101
todo(msl) draw quad
draw quad
probe (0, 0) rgba (100, 100, 100, 100)
[pixel shader]
@ -343,7 +343,7 @@ float4 main() : sv_target
[test]
uniform 0 float 1.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader]
@ -358,7 +358,7 @@ float4 main() : sv_target
[test]
uniform 0 float 1.0
uniform 4 float 2.0
todo(msl) draw quad
draw quad
if(sm<6) probe (0, 0) rgba (2.0, 2.0, 2.0, 2.0)
if(sm>=6) probe (0, 0) rgba(1.0, 1.0, 1.0, 1.0)
@ -374,7 +374,7 @@ float4 main() : sv_target
[test]
uniform 0 float 0.0
uniform 4 float 1.0
todo(msl) draw quad
draw quad
if(sm<6) probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
if(sm>=6) probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0)
@ -390,7 +390,7 @@ float4 main() : sv_target
[test]
uniform 0 float 0.0
uniform 4 float 1.0
todo(msl) draw quad
draw quad
if(sm<6) probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
if(sm>=6) probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0)
@ -406,7 +406,7 @@ float4 main() : sv_target
[test]
uniform 0 float 0.0
uniform 4 float 1.0
todo(msl) draw quad
draw quad
if(sm<6) probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
if(sm>=6) probe (0, 0) rgba (0.0, 0.0, 0.0, 0.0)
@ -421,7 +421,7 @@ float4 main() : sv_target
[test]
uniform 4 float 1.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
% Weird FXC behavior.
@ -437,7 +437,7 @@ float4 main() : sv_target
[test]
uniform 0 float 1.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba(1.0, 1.0, 1.0, 1.0)
% Testing other reservation types. This is a parse failure, i.e "X3530: register sa not valid"
@ -477,7 +477,7 @@ float4 main() : sv_target
[test]
uniform 0 float 0.0
uniform 4 float 2.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba(2.0, 2.0, 2.0, 2.0)
[require]

View File

@ -18,5 +18,5 @@ float4 main() : sv_target
uniform 0 float4 0.1 0.2 0.0 0.0
uniform 4 float4 0.3 0.4 0.0 0.0
uniform 8 float4 0.5 0.6 0.0 0.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (0.2, 0.3, 0.6, 0.5)

View File

@ -9,7 +9,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 11 21 31 -1
uniform 4 float4 12 22 32 -1
todo(msl) draw quad
draw quad
probe (0, 0) rgba (21.0, 31.0, 11.0, 12.0)
@ -24,7 +24,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 11 21 31 -1
uniform 4 float4 12 22 32 -1
todo(msl) draw quad
draw quad
probe (0, 0) rgba (11.0, 31.0, 12.0, 32.0)
@ -40,7 +40,7 @@ float4 main() : sv_target
uniform 0 float4 11 12 -1 -1
uniform 4 float4 21 22 -1 -1
uniform 8 float4 31 32 -1 -1
todo(msl) draw quad
draw quad
probe (0, 0) rgba (11.0, 31.0, 12.0, 32.0)

View File

@ -149,7 +149,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 3.0, 4.0)
@ -166,5 +166,5 @@ float4 main() : sv_target
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 4.0, 2.0, 3.0)

View File

@ -18,7 +18,7 @@ float4 main(uniform float f, uniform int i, uniform uint u, uniform half h) : sv
[test]
uniform 0 float4 123.0 -2.0 456 0.01
todo(msl) draw quad
draw quad
probe (320,240) rgba (123.0, -2.0, 456.0, 0.01)
[pixel shader]

View File

@ -10,7 +10,7 @@ float4 main() : sv_target
[test]
uniform 0 float 3.5
todo(msl) draw quad
draw quad
probe (0, 0) rgba (3.5, 3.5, 3.5, 3.5)
@ -24,7 +24,7 @@ float4 main() : sv_target
[test]
uniform 0 float4 4.0 5.0 6.0 7.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (4.0, 5.0, 4.0, 5.0)
@ -38,5 +38,5 @@ float4 main() : sv_target
[test]
uniform 0 float 3.5
todo(msl) draw quad
draw quad
probe (0, 0) rgba (3.5, 3.5, 3.5, 3.5)

View File

@ -23,7 +23,7 @@ float4 main() : SV_TARGET
[test]
uniform 0 float4 1.0 2.0 3.0 4.0
todo(msl) draw quad
draw quad
probe (0, 0) rgba (1.0, 2.0, 2.0, 3.0)

View File

@ -86,6 +86,18 @@ static MTLVertexFormat get_metal_attribute_format(DXGI_FORMAT format)
}
}
static MTLPrimitiveType get_metal_primitive_type(D3D_PRIMITIVE_TOPOLOGY topology)
{
switch (topology)
{
case D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST:
return MTLPrimitiveTypeTriangle;
default:
fatal_error("Unhandled topology %#x.\n", topology);
}
}
static void trace_messages(const char *messages)
{
const char *p, *end, *line;
@ -284,7 +296,7 @@ static void metal_runner_clear(struct shader_runner *r, struct resource *res, co
return;
}
static bool metal_runner_draw(struct shader_runner *r, D3D_PRIMITIVE_TOPOLOGY primitive_topology,
static bool metal_runner_draw(struct shader_runner *r, D3D_PRIMITIVE_TOPOLOGY topology,
unsigned int vertex_count, unsigned int instance_count)
{
MTLViewport viewport = {0.0, 0.0, 0.0, 0.0, 0.0, 1.0};
@ -305,6 +317,7 @@ static bool metal_runner_draw(struct shader_runner *r, D3D_PRIMITIVE_TOPOLOGY pr
id<MTLRenderPipelineState> pso;
id<MTLBuffer> argument_buffer;
id<MTLBuffer> cb;
bool ret = false;
NSError *err;
struct
@ -444,10 +457,15 @@ static bool metal_runner_draw(struct shader_runner *r, D3D_PRIMITIVE_TOPOLOGY pr
[encoder setRenderPipelineState:pso];
[encoder setViewport:viewport];
[encoder drawPrimitives:get_metal_primitive_type(topology)
vertexStart:0
vertexCount:vertex_count
instanceCount:instance_count];
[encoder endEncoding];
[command_buffer commit];
[command_buffer waitUntilCompleted];
ret = true;
}
done:
@ -461,7 +479,7 @@ done:
runner->d3d_blobs[i] = NULL;
}
return false;
return ret;
}
static bool metal_runner_copy(struct shader_runner *r, struct resource *src, struct resource *dst)