Skip to content

Commit 8480bc6

Browse files
simolltex3d
andauthored
[SM6.10] VEC9 TriangleObjectPositions / CHECK-pass validation tests (#7831)
- DXIL validation tests showing correct uses pass SM6.10 tracking bug: #7824 --------- Co-authored-by: Tex Riddell <[email protected]>
1 parent 532dfa7 commit 8480bc6

5 files changed

Lines changed: 184 additions & 9 deletions

File tree

lib/DXIL/DxilOperations.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4275,6 +4275,7 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
42754275
#define RRT(_y) A(GetResRetType(_y))
42764276
#define CBRT(_y) A(GetCBufferRetType(_y))
42774277
#define VEC4(_y) A(GetStructVectorType(4, _y))
4278+
#define VEC9(_y) A(VectorType::get(_y, 9))
42784279

42794280
// Extended Overload types are wrapped in an anonymous struct
42804281
#define EXT(_y) A(cast<StructType>(pOverloadType)->getElementType(_y))
@@ -6504,25 +6505,25 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
65046505

65056506
// Raytracing System Values
65066507
case OpCode::TriangleObjectPosition:
6507-
A(pETy);
6508+
VEC9(pETy);
65086509
A(pI32);
65096510
break;
65106511

65116512
// Inline Ray Query
65126513
case OpCode::RayQuery_CandidateTriangleObjectPosition:
6513-
A(pETy);
6514+
VEC9(pETy);
65146515
A(pI32);
65156516
A(pI32);
65166517
break;
65176518
case OpCode::RayQuery_CommittedTriangleObjectPosition:
6518-
A(pETy);
6519+
VEC9(pETy);
65196520
A(pI32);
65206521
A(pI32);
65216522
break;
65226523

65236524
// Shader Execution Reordering
65246525
case OpCode::HitObject_TriangleObjectPosition:
6525-
A(pETy);
6526+
VEC9(pETy);
65266527
A(pI32);
65276528
A(pHit);
65286529
break;
@@ -7016,6 +7017,12 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {
70167017
StructType *ST = cast<StructType>(Ty);
70177018
return ST->getElementType(0);
70187019
}
7020+
case OpCode::TriangleObjectPosition:
7021+
case OpCode::RayQuery_CandidateTriangleObjectPosition:
7022+
case OpCode::RayQuery_CommittedTriangleObjectPosition:
7023+
case OpCode::HitObject_TriangleObjectPosition:
7024+
// These return <9 x float> vectors directly
7025+
return cast<VectorType>(Ty)->getElementType();
70197026
case OpCode::MatVecMul:
70207027
case OpCode::MatVecMulAdd:
70217028
if (FT->getNumParams() < 2)
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
; REQUIRES: dxil-1-10
2+
; RUN: %dxv %s | FileCheck %s
3+
4+
; CHECK: Validation succeeded.
5+
6+
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
7+
target triple = "dxil-ms-dx"
8+
9+
%dx.types.Handle = type { i8* }
10+
%struct.Payload = type { <4 x float> }
11+
%struct.BuiltInTriangleIntersectionAttributes = type { <2 x float> }
12+
%dx.types.ResourceProperties = type { i32, i32 }
13+
%dx.types.HitObject = type { i8* }
14+
15+
; Function Attrs: nounwind
16+
define void @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z"(%struct.Payload* noalias nocapture %payload, %struct.BuiltInTriangleIntersectionAttributes* nocapture readnone %attr) #0 {
17+
%1 = call i32 @dx.op.clusterID(i32 -2147483645) ; ClusterID()
18+
ret void
19+
}
20+
21+
; Function Attrs: nounwind
22+
define void @"\01?test_raygeneration@@YAXXZ"() #0 {
23+
%1 = call %dx.types.HitObject @dx.op.hitObject_MakeNop(i32 266) ; HitObject_MakeNop()
24+
%2 = call i32 @dx.op.hitObject_StateScalar.i32(i32 -2147483642, %dx.types.HitObject %1) ; HitObject_ClusterID(hitObject)
25+
%3 = call i32 @dx.op.allocateRayQuery(i32 178, i32 0) ; AllocateRayQuery(constRayFlags)
26+
%4 = call i32 @dx.op.rayQuery_StateScalar.i32(i32 -2147483644, i32 %3) ; RayQuery_CandidateClusterID(rayQueryHandle)
27+
%5 = call i32 @dx.op.rayQuery_StateScalar.i32(i32 -2147483643, i32 %3) ; RayQuery_CommittedClusterID(rayQueryHandle)
28+
ret void
29+
}
30+
31+
; Function Attrs: nounwind readnone
32+
declare i32 @dx.op.clusterID(i32) #1
33+
34+
; Function Attrs: nounwind readnone
35+
declare %dx.types.HitObject @dx.op.hitObject_MakeNop(i32) #1
36+
37+
; Function Attrs: nounwind readnone
38+
declare i32 @dx.op.hitObject_StateScalar.i32(i32, %dx.types.HitObject) #1
39+
40+
; Function Attrs: nounwind
41+
declare i32 @dx.op.allocateRayQuery(i32, i32) #0
42+
43+
; Function Attrs: nounwind readonly
44+
declare i32 @dx.op.rayQuery_StateScalar.i32(i32, i32) #2
45+
46+
attributes #0 = { nounwind }
47+
attributes #1 = { nounwind readnone }
48+
attributes #2 = { nounwind readonly }
49+
50+
!dx.version = !{!0}
51+
!dx.valver = !{!0}
52+
!dx.shaderModel = !{!1}
53+
!dx.typeAnnotations = !{!2}
54+
!dx.dxrPayloadAnnotations = !{!9}
55+
!dx.entryPoints = !{!12, !14, !17}
56+
57+
!0 = !{i32 1, i32 10}
58+
!1 = !{!"lib", i32 6, i32 10}
59+
!2 = !{i32 1, void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !3, void ()* @"\01?test_raygeneration@@YAXXZ", !8}
60+
!3 = !{!4, !6, !7}
61+
!4 = !{i32 1, !5, !5}
62+
!5 = !{}
63+
!6 = !{i32 2, !5, !5}
64+
!7 = !{i32 0, !5, !5}
65+
!8 = !{!4}
66+
!9 = !{i32 0, %struct.Payload undef, !10}
67+
!10 = !{!11}
68+
!11 = !{i32 0, i32 33}
69+
!12 = !{null, !"", null, null, !13}
70+
!13 = !{i32 0, i64 33554432}
71+
!14 = !{void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", null, null, !15}
72+
!15 = !{i32 8, i32 10, i32 6, i32 16, i32 7, i32 8, i32 5, !16}
73+
!16 = !{i32 0}
74+
!17 = !{void ()* @"\01?test_raygeneration@@YAXXZ", !"\01?test_raygeneration@@YAXXZ", null, null, !18}
75+
!18 = !{i32 8, i32 7, i32 5, !16}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
; REQUIRES: dxil-1-10
2+
; RUN: %dxv %s | FileCheck %s
3+
4+
; CHECK: Validation succeeded.
5+
6+
target datalayout = "e-m:e-p:32:32-i1:32-i8:32-i16:32-i32:32-i64:64-f16:32-f32:32-f64:64-n8:16:32:64"
7+
target triple = "dxil-ms-dx"
8+
9+
%dx.types.Handle = type { i8* }
10+
%struct.Payload = type { <4 x float> }
11+
%struct.BuiltInTriangleIntersectionAttributes = type { <2 x float> }
12+
%dx.types.ResourceProperties = type { i32, i32 }
13+
%dx.types.HitObject = type { i8* }
14+
15+
; Function Attrs: nounwind
16+
define void @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z"(%struct.Payload* noalias nocapture %payload, %struct.BuiltInTriangleIntersectionAttributes* nocapture readnone %attr) #0 {
17+
%1 = call <9 x float> @dx.op.triangleObjectPosition.f32(i32 -2147483641) ; TriangleObjectPosition()
18+
ret void
19+
}
20+
21+
; Function Attrs: nounwind
22+
define void @"\01?test_raygeneration@@YAXXZ"() #0 {
23+
%1 = call %dx.types.HitObject @dx.op.hitObject_MakeNop(i32 266) ; HitObject_MakeNop()
24+
%2 = call <9 x float> @dx.op.hitObject_TriangleObjectPosition.f32(i32 -2147483638, %dx.types.HitObject %1) ; HitObject_TriangleObjectPosition(hitObject)
25+
%3 = call i32 @dx.op.allocateRayQuery(i32 178, i32 0) ; AllocateRayQuery(constRayFlags)
26+
%4 = call <9 x float> @dx.op.rayQuery_CandidateTriangleObjectPosition.f32(i32 -2147483640, i32 %3) ; RayQuery_CandidateTriangleObjectPosition(rayQueryHandle)
27+
%5 = call <9 x float> @dx.op.rayQuery_CommittedTriangleObjectPosition.f32(i32 -2147483639, i32 %3) ; RayQuery_CommittedTriangleObjectPosition(rayQueryHandle)
28+
ret void
29+
}
30+
31+
; Function Attrs: nounwind readnone
32+
declare <9 x float> @dx.op.triangleObjectPosition.f32(i32) #1
33+
34+
; Function Attrs: nounwind readnone
35+
declare <9 x float> @dx.op.hitObject_TriangleObjectPosition.f32(i32, %dx.types.HitObject) #1
36+
37+
; Function Attrs: nounwind readnone
38+
declare %dx.types.HitObject @dx.op.hitObject_MakeNop(i32) #1
39+
40+
; Function Attrs: nounwind
41+
declare i32 @dx.op.allocateRayQuery(i32, i32) #0
42+
43+
; Function Attrs: nounwind readonly
44+
declare <9 x float> @dx.op.rayQuery_CandidateTriangleObjectPosition.f32(i32, i32) #2
45+
46+
; Function Attrs: nounwind readonly
47+
declare <9 x float> @dx.op.rayQuery_CommittedTriangleObjectPosition.f32(i32, i32) #2
48+
49+
attributes #0 = { nounwind }
50+
attributes #1 = { nounwind readnone }
51+
attributes #2 = { nounwind readonly }
52+
53+
!dx.version = !{!0}
54+
!dx.valver = !{!0}
55+
!dx.shaderModel = !{!1}
56+
!dx.typeAnnotations = !{!2}
57+
!dx.dxrPayloadAnnotations = !{!9}
58+
!dx.entryPoints = !{!12, !14, !17}
59+
60+
!0 = !{i32 1, i32 10}
61+
!1 = !{!"lib", i32 6, i32 10}
62+
!2 = !{i32 1, void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !3, void ()* @"\01?test_raygeneration@@YAXXZ", !8}
63+
!3 = !{!4, !6, !7}
64+
!4 = !{i32 1, !5, !5}
65+
!5 = !{}
66+
!6 = !{i32 2, !5, !5}
67+
!7 = !{i32 0, !5, !5}
68+
!8 = !{!4}
69+
!9 = !{i32 0, %struct.Payload undef, !10}
70+
!10 = !{!11}
71+
!11 = !{i32 0, i32 33}
72+
!12 = !{null, !"", null, null, !13}
73+
!13 = !{i32 0, i64 33554432}
74+
!14 = !{void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", null, null, !15}
75+
!15 = !{i32 8, i32 10, i32 6, i32 16, i32 7, i32 8, i32 5, !16}
76+
!16 = !{i32 0}
77+
!17 = !{void ()* @"\01?test_raygeneration@@YAXXZ", !"\01?test_raygeneration@@YAXXZ", null, null, !18}
78+
!18 = !{i32 8, i32 7, i32 5, !16}

utils/hct/hctdb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6276,7 +6276,7 @@ def populate_ExperimentalOps(self):
62766276
"f",
62776277
"rn",
62786278
[
6279-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6279+
db_dxil_param(0, "$vec9", "", "operation result"),
62806280
],
62816281
)
62826282
add_dxil_op(
@@ -6286,7 +6286,7 @@ def populate_ExperimentalOps(self):
62866286
"f",
62876287
"ro",
62886288
[
6289-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6289+
db_dxil_param(0, "$vec9", "", "operation result"),
62906290
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
62916291
],
62926292
)
@@ -6297,7 +6297,7 @@ def populate_ExperimentalOps(self):
62976297
"f",
62986298
"ro",
62996299
[
6300-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6300+
db_dxil_param(0, "$vec9", "", "operation result"),
63016301
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
63026302
],
63036303
)
@@ -6308,7 +6308,7 @@ def populate_ExperimentalOps(self):
63086308
"f",
63096309
"rn",
63106310
[
6311-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6311+
db_dxil_param(0, "$vec9", "", "operation result"),
63126312
db_dxil_param(2, "hit_object", "hitObject", "hit"),
63136313
],
63146314
)

utils/hct/hctdb_instrhelp.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ def print_opfunc_table(self):
630630
"u8": "A(pI8);",
631631
"v": "A(pV);",
632632
"$vec4": "VEC4(pETy);",
633+
"$vec9": "VEC9(pETy);",
633634
"SamplePos": "A(pPos);",
634635
"$udt": "A(udt);",
635636
"$obj": "A(obj);",
@@ -684,6 +685,7 @@ def print_opfunc_oload_type(self):
684685
# grouped by the set of overload parameter indices.
685686
extended_dict = collections.OrderedDict()
686687
struct_list = []
688+
vec9_list = [] # For $vec9 operations that return native vectors
687689
extended_list = []
688690

689691
for instr in self.db.get_dxil_ops():
@@ -706,7 +708,11 @@ def print_opfunc_oload_type(self):
706708
continue
707709

708710
if ret_ty.startswith(vec_ty):
709-
struct_list.append(instr.name)
711+
# $vec9 returns native <9 x float> vectors, not struct wrappers
712+
if ret_ty == "$vec9":
713+
vec9_list.append(instr.name)
714+
else:
715+
struct_list.append(instr.name)
710716
continue
711717

712718
in_param_ty = False
@@ -823,6 +829,15 @@ def print_opfunc_oload_type(self):
823829
line = line + "}"
824830
print(line)
825831

832+
# Generate code for $vec9 operations (native <9 x float> vectors)
833+
if vec9_list:
834+
line = ""
835+
for opcode in vec9_list:
836+
line = line + "case OpCode::{name}".format(name=opcode + ":\n")
837+
line = line + " // These return <9 x float> vectors directly\n"
838+
line = line + " return cast<VectorType>(Ty)->getElementType();"
839+
print(line)
840+
826841
for instr in extended_list:
827842
# Collect indices for overloaded return and types, make a tuple of
828843
# indices the key, and add the opcode to a list of opcodes for that

0 commit comments

Comments
 (0)