vkd3d-shader/ir: Transform clip/cull inputs/outputs into arrays.

Takes care of transforming clip/cull system values from the Direct3D
convention of 2 4-component registers, into the SPIR-V/GLSL convention
of 8-element scalar float arrays.

This fixes SPIR-V validation errors in clip-cull-distance.shader_test,
as well as segfaults on Mesa 25.1.1-arch1.2 if those shaders are
executed regardless.

We create indexable temporaries of the appropriate size, and replace
accesses to clip/cull I/O signature elements with accesses to those
temporaries. The existing clip/cull signature elements are then replaced
with new scalar signature element arrays, and we copy the contents of
those I/O signature elements to/from the corresponding temporaries at
the start/end of the vsir program.

It is worth pointing out that the current implementation assumes that
every instance of the control point phase of a hull shader only writes
to the output registers of its control point, given by
vOutputControlPointID, and not to other control points. Shader
compilation will fail if that constraint is violated.
This commit is contained in:
Francisco Casas
2025-08-22 20:08:21 -04:00
committed by Henri Verbeet
parent 85b7b9c6b4
commit 0dabfdee63
Notes: Henri Verbeet 2025-11-25 20:40:54 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1816
4 changed files with 775 additions and 108 deletions

View File

@@ -174,7 +174,7 @@ float4 main(struct vertex_data vertex) : SV_Target
[test]
clear rtv 0 0.0 0.0 0.0 1.0
todo draw triangle list 27
todo(sm<6) draw triangle list 27
probe rtv 0 (160, 120) f32(10.0, 30.0, 50.0, 4984)
probe rtv 0 (160, 240) f32(10.0, 30.0, 50.0, 4984)
probe rtv 0 (160, 360) f32(10.0, 30.0, 50.0, 4984)
@@ -221,7 +221,7 @@ float4 main(struct vertex_data vertex) : SV_Target
[test]
clear rtv 0 0.0 0.0 0.0 1.0
todo draw triangle list 27
todo(sm<6) draw triangle list 27
probe rtv 0 (160, 120) f32(30.0, 50.0, 1.0, 4984)
probe rtv 0 (160, 240) f32(30.0, 50.0, 1.0, 4984)
probe rtv 0 (160, 360) f32(30.0, 50.0, 1.0, 4984)
@@ -568,16 +568,16 @@ void main(triangle vs_out input[3], inout TriangleStream<vs_out> stream)
[test]
clear rtv 0 1.0 1.0 0.0 1.0
todo draw triangle strip 4
probe rtv 0 (160, 120) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (160, 240) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (160, 360) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (320, 120) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (320, 240) rgba(0.0, 1.0, 0.0, 1.0)
probe rtv 0 (320, 360) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (480, 120) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (480, 240) rgba(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (480, 360) rgba(1.0, 1.0, 0.0, 1.0)
todo(sm<6) draw triangle strip 4
probe rtv 0 (160, 120) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (160, 240) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (160, 360) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (320, 120) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (320, 240) f32(0.0, 1.0, 0.0, 1.0)
probe rtv 0 (320, 360) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (480, 120) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (480, 240) f32(1.0, 1.0, 0.0, 1.0)
probe rtv 0 (480, 360) f32(1.0, 1.0, 0.0, 1.0)
% Generate clip and cull distances in the geometry shader.