Skip to content

Commit de4f235

Browse files
authored
[SM6.10] Add DXIL Op support for native vec2 (microsoft#8162)
One of the DXIL ops specified by the LinAlg feature requires the ability to return a vec2, this PR updates the work done for return vec9 to enable that.
1 parent 1e61add commit de4f235

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

lib/DXIL/DxilOperations.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4299,6 +4299,7 @@ Function *OP::GetOpFunc(OpCode opCode, Type *pOverloadType) {
42994299
#define A(_x) ArgTypes.emplace_back(_x)
43004300
#define RRT(_y) A(GetResRetType(_y))
43014301
#define CBRT(_y) A(GetCBufferRetType(_y))
4302+
#define VEC2(_y) A(VectorType::get(_y, 2))
43024303
#define VEC4(_y) A(GetStructVectorType(4, _y))
43034304
#define VEC9(_y) A(VectorType::get(_y, 9))
43044305

@@ -7058,7 +7059,7 @@ llvm::Type *OP::GetOverloadType(OpCode opCode, llvm::Function *F) {
70587059
case OpCode::RayQuery_CandidateTriangleObjectPosition:
70597060
case OpCode::RayQuery_CommittedTriangleObjectPosition:
70607061
case OpCode::HitObject_TriangleObjectPosition:
7061-
// These return <9 x float> vectors directly
7062+
// These return native vectors directly
70627063
return cast<VectorType>(Ty)->getElementType();
70637064
case OpCode::MatVecMul:
70647065
case OpCode::MatVecMulAdd:

utils/hct/hctdb_instrhelp.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ def print_opfunc_table(self):
629629
"u64": "A(pI64);",
630630
"u8": "A(pI8);",
631631
"v": "A(pV);",
632+
"$vec2": "VEC2(pETy);",
632633
"$vec4": "VEC4(pETy);",
633634
"$vec9": "VEC9(pETy);",
634635
"SamplePos": "A(pPos);",
@@ -686,7 +687,7 @@ def print_opfunc_oload_type(self):
686687
# grouped by the set of overload parameter indices.
687688
extended_dict = collections.OrderedDict()
688689
struct_list = []
689-
vec9_list = [] # For $vec9 operations that return native vectors
690+
native_vec_list = [] # For vec operations that return native vectors
690691
extended_list = []
691692

692693
for instr in self.db.get_dxil_ops():
@@ -709,9 +710,9 @@ def print_opfunc_oload_type(self):
709710
continue
710711

711712
if ret_ty.startswith(vec_ty):
712-
# $vec9 returns native <9 x float> vectors, not struct wrappers
713-
if ret_ty == "$vec9":
714-
vec9_list.append(instr.name)
713+
# $vecX returns native vectors, not struct wrappers
714+
if ret_ty in ["$vec2", "$vec9"]:
715+
native_vec_list.append(instr.name)
715716
else:
716717
struct_list.append(instr.name)
717718
continue
@@ -831,11 +832,11 @@ def print_opfunc_oload_type(self):
831832
print(line)
832833

833834
# Generate code for $vec9 operations (native <9 x float> vectors)
834-
if vec9_list:
835+
if native_vec_list:
835836
line = ""
836-
for opcode in vec9_list:
837+
for opcode in native_vec_list:
837838
line = line + "case OpCode::{name}".format(name=opcode + ":\n")
838-
line = line + " // These return <9 x float> vectors directly\n"
839+
line = line + " // These return native vectors directly\n"
839840
line = line + " return cast<VectorType>(Ty)->getElementType();"
840841
print(line)
841842

0 commit comments

Comments
 (0)