Skip to content

Commit 63a5b8b

Browse files
committed
[SM6.10] VEC9 TriangleObjectPositions / passing validation tests
SM6.10 tracking bug: #7824
1 parent 948629a commit 63a5b8b

File tree

5 files changed

+182
-9
lines changed

5 files changed

+182
-9
lines changed

lib/DXIL/DxilOperations.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4081,6 +4081,7 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
40814081
#define RRT(_y) A(GetResRetType(_y))
40824082
#define CBRT(_y) A(GetCBufferRetType(_y))
40834083
#define VEC4(_y) A(GetStructVectorType(4, _y))
4084+
#define VEC9(_y) A(VectorType::get(_y, 9))
40844085

40854086
// Extended Overload types are wrapped in an anonymous struct
40864087
#define EXT(_y) A(cast<StructType>(pOverloadType)->getElementType(_y))
@@ -6310,25 +6311,25 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
63106311

63116312
// Raytracing System Values
63126313
case OpCode::TriangleObjectPosition:
6313-
A(pETy);
6314+
VEC9(pETy);
63146315
A(pI32);
63156316
break;
63166317

63176318
// Inline Ray Query
63186319
case OpCode::RayQuery_CandidateTriangleObjectPosition:
6319-
A(pETy);
6320+
VEC9(pETy);
63206321
A(pI32);
63216322
A(pI32);
63226323
break;
63236324
case OpCode::RayQuery_CommittedTriangleObjectPosition:
6324-
A(pETy);
6325+
VEC9(pETy);
63256326
A(pI32);
63266327
A(pI32);
63276328
break;
63286329

63296330
// Shader Execution Reordering
63306331
case OpCode::HitObject_TriangleObjectPosition:
6331-
A(pETy);
6332+
VEC9(pETy);
63326333
A(pI32);
63336334
A(pHit);
63346335
break;
@@ -6653,6 +6654,12 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {
66536654
StructType *ST = cast<StructType>(Ty);
66546655
return ST->getElementType(0);
66556656
}
6657+
case OpCode::TriangleObjectPosition:
6658+
case OpCode::RayQuery_CandidateTriangleObjectPosition:
6659+
case OpCode::RayQuery_CommittedTriangleObjectPosition:
6660+
case OpCode::HitObject_TriangleObjectPosition:
6661+
// These return <9 x float> vectors directly
6662+
return cast<VectorType>(Ty)->getElementType();
66566663
case OpCode::MatVecMul:
66576664
case OpCode::MatVecMulAdd:
66586665
if (FT->getNumParams() < 2)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
; RUN: %dxv %s | FileCheck %s
2+
3+
; CHECK: Validation succeeded.
4+
5+
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"
6+
target triple = "dxil-ms-dx"
7+
8+
%dx.types.Handle = type { i8* }
9+
%struct.Payload = type { <4 x float> }
10+
%struct.BuiltInTriangleIntersectionAttributes = type { <2 x float> }
11+
%dx.types.ResourceProperties = type { i32, i32 }
12+
%dx.types.HitObject = type { i8* }
13+
14+
; Function Attrs: nounwind
15+
define void @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z"(%struct.Payload* noalias nocapture %payload, %struct.BuiltInTriangleIntersectionAttributes* nocapture readnone %attr) #0 {
16+
%1 = call i32 @dx.op.clusterID(i32 2147483651) ; ClusterID()
17+
ret void
18+
}
19+
20+
; Function Attrs: nounwind
21+
define void @"\01?test_raygeneration@@YAXXZ"() #0 {
22+
%1 = call %dx.types.HitObject @dx.op.hitObject_MakeNop(i32 266) ; HitObject_MakeNop()
23+
%2 = call i32 @dx.op.hitObject_StateScalar.i32(i32 2147483654, %dx.types.HitObject %1) ; HitObject_ClusterID(hitObject)
24+
%3 = call i32 @dx.op.allocateRayQuery(i32 178, i32 0) ; AllocateRayQuery(constRayFlags)
25+
%4 = call i32 @dx.op.rayQuery_StateScalar.i32(i32 2147483652, i32 %3) ; RayQuery_CandidateClusterID(rayQueryHandle)
26+
%5 = call i32 @dx.op.rayQuery_StateScalar.i32(i32 2147483653, i32 %3) ; RayQuery_CommittedClusterID(rayQueryHandle)
27+
ret void
28+
}
29+
30+
; Function Attrs: nounwind readnone
31+
declare i32 @dx.op.clusterID(i32) #1
32+
33+
; Function Attrs: nounwind readnone
34+
declare %dx.types.HitObject @dx.op.hitObject_MakeNop(i32) #1
35+
36+
; Function Attrs: nounwind readnone
37+
declare i32 @dx.op.hitObject_StateScalar.i32(i32, %dx.types.HitObject) #1
38+
39+
; Function Attrs: nounwind
40+
declare i32 @dx.op.allocateRayQuery(i32, i32) #0
41+
42+
; Function Attrs: nounwind readonly
43+
declare i32 @dx.op.rayQuery_StateScalar.i32(i32, i32) #2
44+
45+
attributes #0 = { nounwind }
46+
attributes #1 = { nounwind readnone }
47+
attributes #2 = { nounwind readonly }
48+
49+
!dx.version = !{!0}
50+
!dx.valver = !{!0}
51+
!dx.shaderModel = !{!1}
52+
!dx.typeAnnotations = !{!2}
53+
!dx.dxrPayloadAnnotations = !{!9}
54+
!dx.entryPoints = !{!12, !14, !17}
55+
56+
!0 = !{i32 1, i32 10}
57+
!1 = !{!"lib", i32 6, i32 10}
58+
!2 = !{i32 1, void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !3, void ()* @"\01?test_raygeneration@@YAXXZ", !8}
59+
!3 = !{!4, !6, !7}
60+
!4 = !{i32 1, !5, !5}
61+
!5 = !{}
62+
!6 = !{i32 2, !5, !5}
63+
!7 = !{i32 0, !5, !5}
64+
!8 = !{!4}
65+
!9 = !{i32 0, %struct.Payload undef, !10}
66+
!10 = !{!11}
67+
!11 = !{i32 0, i32 33}
68+
!12 = !{null, !"", null, null, !13}
69+
!13 = !{i32 0, i64 33554432}
70+
!14 = !{void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", null, null, !15}
71+
!15 = !{i32 8, i32 10, i32 6, i32 16, i32 7, i32 8, i32 5, !16}
72+
!16 = !{i32 0}
73+
!17 = !{void ()* @"\01?test_raygeneration@@YAXXZ", !"\01?test_raygeneration@@YAXXZ", null, null, !18}
74+
!18 = !{i32 8, i32 7, i32 5, !16}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
; RUN: %dxv %s | FileCheck %s
2+
3+
; CHECK: Validation succeeded.
4+
5+
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"
6+
target triple = "dxil-ms-dx"
7+
8+
%dx.types.Handle = type { i8* }
9+
%struct.Payload = type { <4 x float> }
10+
%struct.BuiltInTriangleIntersectionAttributes = type { <2 x float> }
11+
%dx.types.ResourceProperties = type { i32, i32 }
12+
%dx.types.HitObject = type { i8* }
13+
14+
; Function Attrs: nounwind
15+
define void @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z"(%struct.Payload* noalias nocapture %payload, %struct.BuiltInTriangleIntersectionAttributes* nocapture readnone %attr) #0 {
16+
%1 = call <9 x float> @dx.op.triangleObjectPosition.f32(i32 2147483655) ; TriangleObjectPosition()
17+
ret void
18+
}
19+
20+
; Function Attrs: nounwind
21+
define void @"\01?test_raygeneration@@YAXXZ"() #0 {
22+
%1 = call %dx.types.HitObject @dx.op.hitObject_MakeNop(i32 266) ; HitObject_MakeNop()
23+
%2 = call <9 x float> @dx.op.hitObject_TriangleObjectPosition.f32(i32 2147483658, %dx.types.HitObject %1) ; HitObject_TriangleObjectPosition(hitObject)
24+
%3 = call i32 @dx.op.allocateRayQuery(i32 178, i32 0) ; AllocateRayQuery(constRayFlags)
25+
%4 = call <9 x float> @dx.op.rayQuery_CandidateTriangleObjectPosition.f32(i32 2147483656, i32 %3) ; RayQuery_CandidateTriangleObjectPosition(rayQueryHandle)
26+
%5 = call <9 x float> @dx.op.rayQuery_CommittedTriangleObjectPosition.f32(i32 2147483657, i32 %3) ; RayQuery_CommittedTriangleObjectPosition(rayQueryHandle)
27+
ret void
28+
}
29+
30+
; Function Attrs: nounwind readnone
31+
declare <9 x float> @dx.op.triangleObjectPosition.f32(i32) #1
32+
33+
; Function Attrs: nounwind readnone
34+
declare <9 x float> @dx.op.hitObject_TriangleObjectPosition.f32(i32, %dx.types.HitObject) #1
35+
36+
; Function Attrs: nounwind readnone
37+
declare %dx.types.HitObject @dx.op.hitObject_MakeNop(i32) #1
38+
39+
; Function Attrs: nounwind
40+
declare i32 @dx.op.allocateRayQuery(i32, i32) #0
41+
42+
; Function Attrs: nounwind readonly
43+
declare <9 x float> @dx.op.rayQuery_CandidateTriangleObjectPosition.f32(i32, i32) #2
44+
45+
; Function Attrs: nounwind readonly
46+
declare <9 x float> @dx.op.rayQuery_CommittedTriangleObjectPosition.f32(i32, i32) #2
47+
48+
attributes #0 = { nounwind }
49+
attributes #1 = { nounwind readnone }
50+
attributes #2 = { nounwind readonly }
51+
52+
!dx.version = !{!0}
53+
!dx.valver = !{!0}
54+
!dx.shaderModel = !{!1}
55+
!dx.typeAnnotations = !{!2}
56+
!dx.dxrPayloadAnnotations = !{!9}
57+
!dx.entryPoints = !{!12, !14, !17}
58+
59+
!0 = !{i32 1, i32 10}
60+
!1 = !{!"lib", i32 6, i32 10}
61+
!2 = !{i32 1, void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !3, void ()* @"\01?test_raygeneration@@YAXXZ", !8}
62+
!3 = !{!4, !6, !7}
63+
!4 = !{i32 1, !5, !5}
64+
!5 = !{}
65+
!6 = !{i32 2, !5, !5}
66+
!7 = !{i32 0, !5, !5}
67+
!8 = !{!4}
68+
!9 = !{i32 0, %struct.Payload undef, !10}
69+
!10 = !{!11}
70+
!11 = !{i32 0, i32 33}
71+
!12 = !{null, !"", null, null, !13}
72+
!13 = !{i32 0, i64 33554432}
73+
!14 = !{void (%struct.Payload*, %struct.BuiltInTriangleIntersectionAttributes*)* @"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", !"\01?test_closesthit@@YAXUPayload@@UBuiltInTriangleIntersectionAttributes@@@Z", null, null, !15}
74+
!15 = !{i32 8, i32 10, i32 6, i32 16, i32 7, i32 8, i32 5, !16}
75+
!16 = !{i32 0}
76+
!17 = !{void ()* @"\01?test_raygeneration@@YAXXZ", !"\01?test_raygeneration@@YAXXZ", null, null, !18}
77+
!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
@@ -6263,7 +6263,7 @@ def populate_ExperimentalOps(self):
62636263
"f",
62646264
"rn",
62656265
[
6266-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6266+
db_dxil_param(0, "$vec9", "", "operation result"),
62676267
],
62686268
)
62696269
add_dxil_op(
@@ -6273,7 +6273,7 @@ def populate_ExperimentalOps(self):
62736273
"f",
62746274
"ro",
62756275
[
6276-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6276+
db_dxil_param(0, "$vec9", "", "operation result"),
62776277
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
62786278
],
62796279
)
@@ -6284,7 +6284,7 @@ def populate_ExperimentalOps(self):
62846284
"f",
62856285
"ro",
62866286
[
6287-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6287+
db_dxil_param(0, "$vec9", "", "operation result"),
62886288
db_dxil_param(2, "i32", "rayQueryHandle", "RayQuery handle"),
62896289
],
62906290
)
@@ -6295,7 +6295,7 @@ def populate_ExperimentalOps(self):
62956295
"f",
62966296
"rn",
62976297
[
6298-
db_dxil_param(0, "$o", "", "operation result"), # TODO: $vec9
6298+
db_dxil_param(0, "$vec9", "", "operation result"),
62996299
db_dxil_param(2, "hit_object", "hitObject", "hit"),
63006300
],
63016301
)

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);",
@@ -683,6 +684,7 @@ def print_opfunc_oload_type(self):
683684
# grouped by the set of overload parameter indices.
684685
extended_dict = collections.OrderedDict()
685686
struct_list = []
687+
vec9_list = [] # For $vec9 operations that return native vectors
686688
extended_list = []
687689

688690
for instr in self.db.get_dxil_ops():
@@ -705,7 +707,11 @@ def print_opfunc_oload_type(self):
705707
continue
706708

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

711717
in_param_ty = False
@@ -822,6 +828,15 @@ def print_opfunc_oload_type(self):
822828
line = line + "}"
823829
print(line)
824830

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

0 commit comments

Comments
 (0)