Skip to content

Commit 4cce356

Browse files
authored
spirv-val: Interpolation functions with half (KhronosGroup#6653)
The SPV_AMD_gpu_shader_half_float extension allows us to use half type in interpolation functions. If this extension is declared in the SPIR-V, interpolation functions with half are considered valid. Other cases are still invalid.
1 parent e152004 commit 4cce356

2 files changed

Lines changed: 337 additions & 16 deletions

File tree

source/val/validate_extensions.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,11 +1996,16 @@ spv_result_t ValidateExtInstGlslStd450(ValidationState_t& _,
19961996
}
19971997

19981998
if (!_.IsFloatScalarOrVectorType(result_type) ||
1999-
_.GetBitWidth(result_type) != 32) {
1999+
(_.GetBitWidth(result_type) != 32 &&
2000+
(!_.HasExtension(kSPV_AMD_gpu_shader_half_float) ||
2001+
_.GetBitWidth(result_type) != 16))) {
20002002
return _.diag(SPV_ERROR_INVALID_DATA, inst)
20012003
<< GetExtInstName(_, inst) << ": "
2002-
<< "expected Result Type to be a 32-bit float scalar "
2003-
<< "or vector type";
2004+
<< "expected Result Type to be a "
2005+
<< (_.HasExtension(kSPV_AMD_gpu_shader_half_float)
2006+
? "16-bit or 32-bit "
2007+
: "32-bit ")
2008+
<< "float scalar or vector type";
20042009
}
20052010

20062011
// If HLSL legalization and first operand is an OpLoad, use load
@@ -2047,10 +2052,16 @@ spv_result_t ValidateExtInstGlslStd450(ValidationState_t& _,
20472052
const uint32_t offset_type = _.GetOperandTypeId(inst, 5);
20482053
if (!_.IsFloatVectorType(offset_type) ||
20492054
_.GetDimension(offset_type) != 2 ||
2050-
_.GetBitWidth(offset_type) != 32) {
2055+
(_.GetBitWidth(offset_type) != 32 &&
2056+
(!_.HasExtension(kSPV_AMD_gpu_shader_half_float) ||
2057+
_.GetBitWidth(offset_type) != 16))) {
20512058
return _.diag(SPV_ERROR_INVALID_DATA, inst)
20522059
<< GetExtInstName(_, inst) << ": "
2053-
<< "expected Offset to be a vector of 2 32-bit floats";
2060+
<< "expected Offset to be a vector of 2 "
2061+
<< (_.HasExtension(kSPV_AMD_gpu_shader_half_float)
2062+
? "16-bit or 32-bit "
2063+
: "32-bit ")
2064+
<< "floats";
20542065
}
20552066
}
20562067

0 commit comments

Comments
 (0)