Skip to content

Commit b8a502e

Browse files
committed
revise overload resolution for splats/truncations
Allow truncations when matching arguments for intrinsic overloads. This eliminates the need for explicit scalar extractions from vectors for arguments that are scalar by nature. This encompasses any vectors passed for scalars, allowing the truncation, but emitting a warning the same as is done for other assignments of vectors to scalars. This maintains splats as the preferred transformations and promotes perfect matches to be preferred over that. This has the effect of removing the need to carefully order intrinsics to ensure that the right variant gets matched first before another one incorrectly takes its place with a faulty cast. Allowing truncations causes a problems with a small subset of intrinsics that have explicit overloads for various matrix,vector, scalar combinations. Namely the mul overloads. These could be simplified to accept a new range of template types except the dimensions need to be matched in unconventional ways. For these, the notion of uncastable or "ONLY" variants of the template/layout types are introduced. These are indicated with a trailing "!" after the parameter typename in gen_intrin_main, which directs them to an array that contains a NOCAST enum that, when encountered, will skip the attempts to splat or truncate. Fixes microsoft#7079
1 parent c65a179 commit b8a502e

File tree

7 files changed

+88
-90
lines changed

7 files changed

+88
-90
lines changed

include/dxc/dxcapi.internal.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ enum LEGAL_INTRINSIC_TEMPLATES {
4646
4, // Any one of scalar, vector or matrix types (but not object).
4747
LITEMPLATE_OBJECT = 5, // Object types.
4848
LITEMPLATE_ARRAY = 6, // Scalar array.
49+
LITEMPLATE_SCALAR_ONLY = 7, // Uncastable scalar types.
50+
LITEMPLATE_VECTOR_ONLY = 8, // Uncastable vector types (eg. float3).
51+
LITEMPLATE_MATRIX_ONLY = 9, // Uncastable matrix types (eg. float3x3).
4952

50-
LITEMPLATE_COUNT = 7
53+
LITEMPLATE_COUNT = 10
5154
};
5255

5356
// INTRIN_COMPTYPE_FROM_TYPE_ELT0 is for object method intrinsics to indicate

lib/HLSL/HLOperationLower.cpp

+5-30
Original file line numberDiff line numberDiff line change
@@ -4196,12 +4196,10 @@ void TranslateLoad(ResLoadHelper &helper, HLResource::Kind RK,
41964196
loadArgs.emplace_back(opArg); // opcode
41974197
loadArgs.emplace_back(helper.handle); // resource handle
41984198

4199+
// offsets
41994200
if (opcode == OP::OpCode::TextureLoad) {
42004201
// set mip level
42014202
loadArgs.emplace_back(helper.mipLevel);
4202-
}
4203-
4204-
if (opcode == OP::OpCode::TextureLoad) {
42054203
// texture coord
42064204
unsigned coordSize = DxilResource::GetNumCoords(RK);
42074205
bool isVectorAddr = helper.addr->getType()->isVectorTy();
@@ -4213,22 +4211,6 @@ void TranslateLoad(ResLoadHelper &helper, HLResource::Kind RK,
42134211
} else
42144212
loadArgs.emplace_back(undefI);
42154213
}
4216-
} else {
4217-
if (helper.addr->getType()->isVectorTy()) {
4218-
Value *scalarOffset =
4219-
Builder.CreateExtractElement(helper.addr, (uint64_t)0);
4220-
4221-
// TODO: calculate the real address based on opcode
4222-
4223-
loadArgs.emplace_back(scalarOffset); // offset
4224-
} else {
4225-
// TODO: calculate the real address based on opcode
4226-
4227-
loadArgs.emplace_back(helper.addr); // offset
4228-
}
4229-
}
4230-
// offset 0
4231-
if (opcode == OP::OpCode::TextureLoad) {
42324214
if (helper.offset && !isa<llvm::UndefValue>(helper.offset)) {
42334215
unsigned offsetSize = DxilResource::GetNumOffsets(RK);
42344216
for (unsigned i = 0; i < 3; i++) {
@@ -4242,11 +4224,9 @@ void TranslateLoad(ResLoadHelper &helper, HLResource::Kind RK,
42424224
loadArgs.emplace_back(undefI);
42434225
loadArgs.emplace_back(undefI);
42444226
}
4245-
}
4246-
4247-
// Offset 1
4248-
if (RK == DxilResource::Kind::TypedBuffer) {
4249-
loadArgs.emplace_back(undefI);
4227+
} else {
4228+
loadArgs.emplace_back(helper.addr); // c0
4229+
loadArgs.emplace_back(undefI); // c1
42504230
}
42514231

42524232
Value *ResRet = Builder.CreateCall(F, loadArgs, OP->GetOpCodeName(opcode));
@@ -4420,12 +4400,7 @@ void TranslateStore(DxilResource::Kind RK, Value *handle, Value *val,
44204400
if (RK == DxilResource::Kind::RawBuffer ||
44214401
RK == DxilResource::Kind::TypedBuffer) {
44224402
// Offset 0
4423-
if (offset->getType()->isVectorTy()) {
4424-
Value *scalarOffset = Builder.CreateExtractElement(offset, (uint64_t)0);
4425-
storeArgs.emplace_back(scalarOffset); // offset
4426-
} else {
4427-
storeArgs.emplace_back(offset); // offset
4428-
}
4403+
storeArgs.emplace_back(offset); // offset
44294404

44304405
// Store offset0 for later use
44314406
offset0Idx = storeArgs.size() - 1;

tools/clang/lib/Sema/SemaHLSL.cpp

+43-10
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ enum ArTypeObjectKind {
662662
// indexer object used to implement .mips[1].
663663
AR_TOBJ_STRING, // Represents a string
664664
AR_TOBJ_DEPENDENT, // Dependent type for template.
665+
AR_TOBJ_NOCAST, // Parameter should not have layout casts (splat,trunc)
665666
};
666667

667668
enum TYPE_CONVERSION_FLAGS {
@@ -989,9 +990,15 @@ static const ArTypeObjectKind g_NullTT[] = {AR_TOBJ_VOID, AR_TOBJ_UNKNOWN};
989990

990991
static const ArTypeObjectKind g_ArrayTT[] = {AR_TOBJ_ARRAY, AR_TOBJ_UNKNOWN};
991992

993+
static const ArTypeObjectKind g_ScalarOnlyTT[] = {AR_TOBJ_SCALAR, AR_TOBJ_NOCAST, AR_TOBJ_UNKNOWN};
994+
995+
static const ArTypeObjectKind g_VectorOnlyTT[] = {AR_TOBJ_VECTOR, AR_TOBJ_NOCAST, AR_TOBJ_UNKNOWN};
996+
997+
static const ArTypeObjectKind g_MatrixOnlyTT[] = {AR_TOBJ_MATRIX, AR_TOBJ_NOCAST, AR_TOBJ_UNKNOWN};
998+
992999
const ArTypeObjectKind *g_LegalIntrinsicTemplates[] = {
9931000
g_NullTT, g_ScalarTT, g_VectorTT, g_MatrixTT,
994-
g_AnyTT, g_ObjectTT, g_ArrayTT,
1001+
g_AnyTT, g_ObjectTT, g_ArrayTT, g_ScalarOnlyTT, g_VectorOnlyTT, g_MatrixOnlyTT,
9951002
};
9961003
C_ASSERT(ARRAYSIZE(g_LegalIntrinsicTemplates) == LITEMPLATE_COUNT);
9971004

@@ -6113,7 +6120,7 @@ bool HLSLExternalSource::MatchArguments(
61136120
ArBasicKind
61146121
ComponentType[MaxIntrinsicArgs]; // Component type for each argument,
61156122
// AR_BASIC_UNKNOWN if unspecified.
6116-
UINT uSpecialSize[IA_SPECIAL_SLOTS]; // row/col matching types, UNUSED_INDEX32
6123+
UINT uSpecialSize[IA_SPECIAL_SLOTS]; // row/col matching types, UnusedSize
61176124
// if unspecified.
61186125
badArgIdx = MaxIntrinsicArgs;
61196126

@@ -6249,12 +6256,14 @@ bool HLSLExternalSource::MatchArguments(
62496256
"otherwise intrinsic table was modified and g_MaxIntrinsicParamCount "
62506257
"was not updated (or uTemplateId is out of bounds)");
62516258

6252-
// Compare template
6259+
// Compare template to any type matching params requirements.
62536260
if ((AR_TOBJ_UNKNOWN == Template[pIntrinsicArg->uTemplateId]) ||
62546261
((AR_TOBJ_SCALAR == Template[pIntrinsicArg->uTemplateId]) &&
62556262
(AR_TOBJ_VECTOR == TypeInfoShapeKind ||
62566263
AR_TOBJ_MATRIX == TypeInfoShapeKind))) {
6257-
// Unrestricted or truncation of tuples to scalars are allowed
6264+
// Previous params gave no type restrictions
6265+
// or truncation of tuples to scalars are allowed
6266+
// Later steps harmonize common typed params and will always convert the earlier arg into a splat instead.
62586267
Template[pIntrinsicArg->uTemplateId] = TypeInfoShapeKind;
62596268
} else if (AR_TOBJ_SCALAR == TypeInfoShapeKind) {
62606269
if (AR_TOBJ_SCALAR != Template[pIntrinsicArg->uTemplateId] &&
@@ -6292,6 +6301,11 @@ bool HLSLExternalSource::MatchArguments(
62926301
}
62936302
}
62946303

6304+
// If the intrinsic parameter has variable rows or columns but must match
6305+
// other argument dimensions, it will be specified in pIntrinsicArg with
6306+
// a special value indicating that the dimension depends on the passed values.
6307+
// uSpecialSize stores the dimensions of the actual passed type.
6308+
62956309
// Rows
62966310
if (AR_TOBJ_SCALAR != TypeInfoShapeKind) {
62976311
if (pIntrinsicArg->uRows >= IA_SPECIAL_BASE) {
@@ -6398,18 +6412,37 @@ bool HLSLExternalSource::MatchArguments(
63986412
const ArTypeObjectKind *pTT =
63996413
g_LegalIntrinsicTemplates[pArgument->uLegalTemplates];
64006414
if (AR_TOBJ_UNKNOWN != Template[i]) {
6401-
if ((AR_TOBJ_SCALAR == Template[i]) &&
6402-
(AR_TOBJ_VECTOR == *pTT || AR_TOBJ_MATRIX == *pTT)) {
6403-
Template[i] = *pTT;
6404-
} else {
6415+
// See if a perfect match overload is available
6416+
while (AR_TOBJ_UNKNOWN != *pTT && AR_TOBJ_NOCAST != *pTT) {
6417+
if (Template[i] == *pTT)
6418+
break;
6419+
pTT++;
6420+
}
6421+
6422+
if (AR_TOBJ_UNKNOWN == *pTT) {
6423+
// Perfect match failed and casts are allowed.
6424+
// Try splats and truncations to get a match.
6425+
pTT = g_LegalIntrinsicTemplates[pArgument->uLegalTemplates];
64056426
while (AR_TOBJ_UNKNOWN != *pTT) {
6406-
if (Template[i] == *pTT)
6427+
if (AR_TOBJ_SCALAR == Template[i] &&
6428+
(AR_TOBJ_VECTOR == *pTT || AR_TOBJ_MATRIX == *pTT)) {
6429+
// If a scalar was passed in and the expected value was matrix/vector
6430+
// convert to the template type for a splat.
6431+
// Only applicable to VectorTT and MatrixTT, since the vec/mtx has to be first in the list.
6432+
Template[i] = *pTT;
64076433
break;
6434+
} else if (AR_TOBJ_VECTOR == Template[i] && AR_TOBJ_SCALAR == *pTT) {
6435+
// If a vector was passed in and the expected value was scalar
6436+
// convert to the template type for a truncation.
6437+
// Only applicable to ScalarTT, since the scalar has to be first in the list.
6438+
Template[i] = AR_TOBJ_SCALAR;
6439+
break;
6440+
}
64086441
pTT++;
64096442
}
64106443
}
64116444

6412-
if (AR_TOBJ_UNKNOWN == *pTT) {
6445+
if (AR_TOBJ_UNKNOWN == *pTT || AR_TOBJ_NOCAST == *pTT) {
64136446
Template[i] = g_LegalIntrinsicTemplates[pArgument->uLegalTemplates][0];
64146447
badArgIdx = std::min(badArgIdx, i);
64156448
}

tools/clang/test/HLSLFileCheck/hlsl/intrinsics/compound/refract.hlsl

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
// RUN: %dxc -E main -T vs_6_2 -DTY1=float3 -DTY2=bool -enable-16bit-types %s | FileCheck %s
1414
// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t -enable-16bit-types %s | FileCheck %s
1515

16+
// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t4 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK
17+
// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=float16_t2 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK
18+
1619
// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t4x4 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
17-
// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=uint16_t4 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
18-
// RUN: %dxc -E main -T vs_6_2 -DTY1=float4 -DTY2=float16_t2 -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
1920
// RUN: %dxc -E main -T vs_6_2 -DTY1=uint16_t4x4 -DTY2=float16_t -enable-16bit-types %s | FileCheck %s -check-prefix=CHECK_ERROR
2021

2122
// CHECK: define void @main()
2223
// CHECK_ERROR: note: candidate function not viable: no known conversion from
2324

2425
TY1 main (TY1 a: IN0, TY1 b : IN1, TY2 c : IN2) : OUT {
2526
return refract(a, b, c);
26-
}
27+
}

tools/clang/test/SemaHLSL/intrinsic-examples.hlsl

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ float4 RWByteAddressBufferMain(uint2 a : A, uint2 b : B) : SV_Target
1818
uint status;
1919
// TODO - fix the following error - the subscript exist, but the indexer type is incorrect - message is misleading
2020
r += uav1[b]; // expected-error {{type 'RWByteAddressBuffer' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
21-
r += uav1.Load(a); // expected-error {{no matching member function for call to 'Load'}} expected-note {{candidate function template not viable: requires 2 arguments, but 1 was provided}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint)}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint, out uint status)}} fxc-error {{X3013: 'Load': no matching 1 parameter intrinsic method}} fxc-error {{X3013: Possible intrinsic methods are:}}
22-
uav1.Load(a, status); // expected-error {{no matching member function for call to 'Load'}} expected-note {{candidate function template not viable: requires single argument 'byteOffset', but 2 arguments were provided}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint)}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint, out uint status)}} fxc-error {{X3013: 'Load': no matching 2 parameter intrinsic method}} fxc-error {{X3013: Possible intrinsic methods are:}}
21+
r += uav1.Load(a); // expected-warning {{implicit truncation of vector type}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint)}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint, out uint status)}} fxc-error {{X3013: 'Load': no matching 1 parameter intrinsic method}} fxc-error {{X3013: Possible intrinsic methods are:}}
22+
uav1.Load(a, status); // expected-warning {{implicit truncation of vector type}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint)}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint, out uint status)}} fxc-error {{X3013: 'Load': no matching 2 parameter intrinsic method}} fxc-error {{X3013: Possible intrinsic methods are:}}
2323
r += status;
24-
uav1.Load(a, status); // expected-error {{no matching member function for call to 'Load'}} expected-note {{requires single argument 'byteOffset', but 2 arguments were provided}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint)}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint, out uint status)}} fxc-error {{X3013: 'Load': no matching 2 parameter intrinsic method}} fxc-error {{X3013: Possible intrinsic methods are:}}
24+
uav1.Load(a, status); // expected-warning {{implicit truncation of vector type}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint)}} fxc-error {{X3013: RWByteAddressBuffer<uint>.Load(uint, out uint status)}} fxc-error {{X3013: 'Load': no matching 2 parameter intrinsic method}} fxc-error {{X3013: Possible intrinsic methods are:}}
2525
r += status;
2626
uav1[b] = r; // expected-error {{type 'RWByteAddressBuffer' does not provide a subscript operator}} fxc-error {{X3121: array, matrix, vector, or indexable object type expected in index expression}}
2727
uav1.Load(a.x, status);

utils/hct/gen_intrin_main.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ $type1 [[rn,unsigned_op=umax]] max(in numeric<> a, in $type1 b);
198198
$type1 [[rn,unsigned_op=umin]] min(in numeric<> a, in $type1 b);
199199
$type1 [[]] modf(in float_like<> x, out $type1 ip);
200200
uint<4> [[rn]] msad4(in uint reference, in uint<2> source, in uint<4> accum);
201-
numeric [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric a, in $match<2, 0> numeric b) : mul_ss;
202-
numeric<c2> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric a, in $match<2, 0> numeric<c2> b) : mul_sv;
203-
numeric<r2, c2> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric a, in $match<2, 0> numeric<r2, c2> b) : mul_sm;
204-
numeric<c> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<c> a, in $match<2, 0> numeric b) : mul_vs;
205-
numeric [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<c> a, in $match<2, 0> numeric<c> b) : mul_vv;
206-
numeric<c2> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<c> a, in col_major $match<2, 0> numeric<c, c2> b) : mul_vm;
207-
numeric<r, c> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<r, c> a, in $match<2, 0> numeric b) : mul_ms;
208-
numeric<r> [[rn,unsigned_op=umul]] mul(in row_major $match<1, 0> numeric<r, c> a, in $match<2, 0> numeric<c> b) : mul_mv;
209-
numeric<r, c2> [[rn,unsigned_op=umul]] mul(in row_major $match<1, 0> numeric<r, c> a, in col_major $match<2, 0> numeric<c, c2> b) : mul_mm;
201+
numeric [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric! a, in $match<2, 0> numeric! b) : mul_ss;
202+
numeric<c2> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric! a, in $match<2, 0> numeric<c2>! b) : mul_sv;
203+
numeric<r2, c2> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric! a, in $match<2, 0> numeric<r2, c2>! b) : mul_sm;
204+
numeric<c> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<c>! a, in $match<2, 0> numeric! b) : mul_vs;
205+
numeric [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<c>! a, in $match<2, 0> numeric<c>! b) : mul_vv;
206+
numeric<c2> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<c>! a, in col_major $match<2, 0> numeric<c, c2>! b) : mul_vm;
207+
numeric<r, c> [[rn,unsigned_op=umul]] mul(in $match<1, 0> numeric<r, c>! a, in $match<2, 0> numeric! b) : mul_ms;
208+
numeric<r> [[rn,unsigned_op=umul]] mul(in row_major $match<1, 0> numeric<r, c>! a, in $match<2, 0> numeric<c>! b) : mul_mv;
209+
numeric<r, c2> [[rn,unsigned_op=umul]] mul(in row_major $match<1, 0> numeric<r, c>! a, in col_major $match<2, 0> numeric<c, c2>! b) : mul_mm;
210210
$type1 [[rn]] normalize(in float_like<c> x);
211211
$type1 [[rn]] pow(in float_like<> x, in $type1 y);
212212
void [[]] printf(in string Format, ...);
@@ -849,8 +849,8 @@ $match<0, -1> void<4> [[]] GatherCmpAlpha(in sampler_cmp s, in float<4> x, in fl
849849
namespace BufferMethods {
850850

851851
void [[]] GetDimensions(out uint_only width) : bufinfo;
852-
$classT [[ro]] Load(in int<1> x) : buffer_load;
853-
$classT [[]] Load(in int<1> x, out uint_only status) : buffer_load_s;
852+
$classT [[ro]] Load(in int x) : buffer_load;
853+
$classT [[]] Load(in int x, out uint_only status) : buffer_load_s;
854854

855855
} namespace
856856

utils/hct/hctdb.py

+18-32
Original file line numberDiff line numberDiff line change
@@ -8330,13 +8330,13 @@ def load_intrinsics(self, intrinsic_defs):
83308330
params_split_re = re.compile(r"\s*,\s*")
83318331
ws_split_re = re.compile(r"\s+")
83328332
typeref_re = re.compile(r"\$type(\d+)$")
8333-
type_matrix_re = re.compile(r"(\S+)<(\S+)@(\S+)>$")
8334-
type_vector_re = re.compile(r"(\S+)<(\S+)>$")
8333+
type_matrix_re = re.compile(r"(\S+)<(\S+)@(\S+)>(\!?)$")
8334+
type_vector_re = re.compile(r"(\S+)<(\S+)>(\!?)$")
83358335
type_any_re = re.compile(r"(\S+)<>$")
83368336
type_array_re = re.compile(r"(\S+)\[\]$")
83378337
type_object_re = re.compile(
83388338
r"""(
8339-
sampler\w* | string |
8339+
sampler\w* | any_sampler\w* | string |
83408340
(?:RW)?(?:Texture\w*|ByteAddressBuffer) |
83418341
acceleration_struct | ray_desc |
83428342
Node\w* | RWNode\w* | EmptyNode\w* |
@@ -8381,6 +8381,7 @@ def process_arg(desc, idx, done_args, intrinsic_name):
83818381
component_list = "LICOMPTYPE_ANY"
83828382
rows = "1"
83838383
cols = "1"
8384+
only = ""
83848385
if type_name == "$classT":
83858386
assert idx == 0, "'$classT' can only be used as the return type"
83868387
# template_id may be -1 in other places other than return type, for example in Stream.Append().
@@ -8415,13 +8416,19 @@ def process_arg(desc, idx, done_args, intrinsic_name):
84158416
base_type = type_name
84168417

84178418
def do_matrix(m):
8418-
base_type, rows, cols = m.groups()
8419-
template_list = "LITEMPLATE_MATRIX"
8419+
base_type, rows, cols, only = m.groups()
8420+
if only == "!":
8421+
template_list = "LITEMPLATE_MATRIX_ONLY"
8422+
else:
8423+
template_list = "LITEMPLATE_MATRIX"
84208424
return base_type, rows, cols, template_list
84218425

84228426
def do_vector(m):
8423-
base_type, cols = m.groups()
8424-
template_list = "LITEMPLATE_VECTOR"
8427+
base_type, cols, only = m.groups()
8428+
if only == "!":
8429+
template_list = "LITEMPLATE_VECTOR_ONLY"
8430+
else:
8431+
template_list = "LITEMPLATE_VECTOR"
84258432
return base_type, rows, cols, template_list
84268433

84278434
def do_any(m):
@@ -8454,32 +8461,11 @@ def do_object(m):
84548461
base_type, rows, cols, template_list = do(m)
84558462
break
84568463
else:
8457-
type_vector_match = type_vector_re.match(type_name)
8458-
if type_vector_match:
8459-
base_type = type_vector_match.group(1)
8460-
cols = type_vector_match.group(2)
8461-
template_list = "LITEMPLATE_VECTOR"
8464+
if type_name[-1] == "!":
8465+
template_list = "LITEMPLATE_SCALAR_ONLY"
8466+
base_type = type_name[:-1]
84628467
else:
8463-
type_any_match = type_any_re.match(type_name)
8464-
if type_any_match:
8465-
base_type = type_any_match.group(1)
8466-
rows = "r"
8467-
cols = "c"
8468-
template_list = "LITEMPLATE_ANY"
8469-
else:
8470-
base_type = type_name
8471-
if (
8472-
base_type.startswith("sampler")
8473-
or base_type.startswith("string")
8474-
or base_type.startswith("Texture")
8475-
or base_type.startswith("wave")
8476-
or base_type.startswith("acceleration_struct")
8477-
or base_type.startswith("ray_desc")
8478-
or base_type.startswith("any_sampler")
8479-
):
8480-
template_list = "LITEMPLATE_OBJECT"
8481-
else:
8482-
template_list = "LITEMPLATE_SCALAR"
8468+
template_list = "LITEMPLATE_SCALAR"
84838469
assert base_type in self.base_types, "Unknown base type '%s' in '%s'" % (
84848470
base_type,
84858471
desc,

0 commit comments

Comments
 (0)