Prefer KHR to NV for opcode aliases when making SPIR-V helpers

This commit is contained in:
baldurk
2024-04-26 13:55:19 +01:00
parent c098971f79
commit ce7a23b611
4 changed files with 35 additions and 24 deletions
@@ -895,6 +895,19 @@ disassemble = ''
for inst in spirv['instructions']:
if inst['class'] == '@exclude':
continue
wait_for_official = False
for off in official_suffixes:
for vend in vendor_suffixes:
if inst['opname'][-len(vend):] == vend:
off_name = inst['opname'][:-len(vend)] + off
for search in spirv['instructions']:
if search['opname'] == off_name and inst['opcode'] == search['opcode']:
wait_for_official = True
if wait_for_official:
continue
decl += ' {} = {},\n'.format(inst['opname'][2:], inst['opcode'])
+12 -12
View File
@@ -1869,14 +1869,14 @@ rdcstr DoStringise(const rdcspv::Op &el)
STRINGISE_ENUM_CLASS(WritePackedPrimitiveIndices4x8NV);
STRINGISE_ENUM_CLASS(FetchMicroTriangleVertexPositionNV);
STRINGISE_ENUM_CLASS(FetchMicroTriangleVertexBarycentricNV);
STRINGISE_ENUM_CLASS(ReportIntersectionNV);
STRINGISE_ENUM_CLASS(ReportIntersectionKHR);
STRINGISE_ENUM_CLASS(IgnoreIntersectionNV);
STRINGISE_ENUM_CLASS(TerminateRayNV);
STRINGISE_ENUM_CLASS(TraceNV);
STRINGISE_ENUM_CLASS(TraceMotionNV);
STRINGISE_ENUM_CLASS(TraceRayMotionNV);
STRINGISE_ENUM_CLASS(RayQueryGetIntersectionTriangleVertexPositionsKHR);
STRINGISE_ENUM_CLASS(TypeAccelerationStructureNV);
STRINGISE_ENUM_CLASS(TypeAccelerationStructureKHR);
STRINGISE_ENUM_CLASS(ExecuteCallableNV);
STRINGISE_ENUM_CLASS(TypeCooperativeMatrixNV);
STRINGISE_ENUM_CLASS(CooperativeMatrixLoadNV);
@@ -4867,7 +4867,7 @@ void OpDecoder::ForEachID(const ConstIter &it, const std::function<void(Id,bool)
callback(Id::fromWord(it.word(6)), false);
callback(Id::fromWord(it.word(7)), false);
break;
case rdcspv::Op::ReportIntersectionNV:
case rdcspv::Op::ReportIntersectionKHR:
callback(Id::fromWord(it.word(1)), false);
callback(Id::fromWord(it.word(2)), true);
callback(Id::fromWord(it.word(3)), false);
@@ -4924,7 +4924,7 @@ void OpDecoder::ForEachID(const ConstIter &it, const std::function<void(Id,bool)
callback(Id::fromWord(it.word(3)), false);
callback(Id::fromWord(it.word(4)), false);
break;
case rdcspv::Op::TypeAccelerationStructureNV:
case rdcspv::Op::TypeAccelerationStructureKHR:
callback(Id::fromWord(it.word(1)), true);
break;
case rdcspv::Op::ExecuteCallableNV:
@@ -10541,11 +10541,11 @@ rdcstr OpDecoder::Disassemble(const ConstIter &it, const std::function<rdcstr(Id
+ ")";
break;
}
case rdcspv::Op::ReportIntersectionNV:
case rdcspv::Op::ReportIntersectionKHR:
{
OpReportIntersectionNV decoded(it);
OpReportIntersectionKHR decoded(it);
ret += declName(decoded.resultType, decoded.result) + " = ";
ret += rdcstr("ReportIntersectionNV("_lit)
ret += rdcstr("ReportIntersectionKHR("_lit)
+ ParamToStr(idName, decoded.hit)
+ ", "
+ ParamToStr(idName, decoded.hitKind)
@@ -10665,11 +10665,11 @@ rdcstr OpDecoder::Disassemble(const ConstIter &it, const std::function<rdcstr(Id
+ ")";
break;
}
case rdcspv::Op::TypeAccelerationStructureNV:
case rdcspv::Op::TypeAccelerationStructureKHR:
{
OpTypeAccelerationStructureNV decoded(it);
OpTypeAccelerationStructureKHR decoded(it);
ret += idName(decoded.result) + " = ";
ret += rdcstr("TypeAccelerationStructureNV("_lit)
ret += rdcstr("TypeAccelerationStructureKHR("_lit)
+ ")";
break;
}
@@ -12085,14 +12085,14 @@ OpDecoder::OpDecoder(const ConstIter &it)
case rdcspv::Op::WritePackedPrimitiveIndices4x8NV: result = Id(); resultType = Id(); break;
case rdcspv::Op::FetchMicroTriangleVertexPositionNV: result = Id::fromWord(it.word(2)); resultType = Id::fromWord(it.word(1)); break;
case rdcspv::Op::FetchMicroTriangleVertexBarycentricNV: result = Id::fromWord(it.word(2)); resultType = Id::fromWord(it.word(1)); break;
case rdcspv::Op::ReportIntersectionNV: result = Id::fromWord(it.word(2)); resultType = Id::fromWord(it.word(1)); break;
case rdcspv::Op::ReportIntersectionKHR: result = Id::fromWord(it.word(2)); resultType = Id::fromWord(it.word(1)); break;
case rdcspv::Op::IgnoreIntersectionNV: result = Id(); resultType = Id(); break;
case rdcspv::Op::TerminateRayNV: result = Id(); resultType = Id(); break;
case rdcspv::Op::TraceNV: result = Id(); resultType = Id(); break;
case rdcspv::Op::TraceMotionNV: result = Id(); resultType = Id(); break;
case rdcspv::Op::TraceRayMotionNV: result = Id(); resultType = Id(); break;
case rdcspv::Op::RayQueryGetIntersectionTriangleVertexPositionsKHR: result = Id::fromWord(it.word(2)); resultType = Id::fromWord(it.word(1)); break;
case rdcspv::Op::TypeAccelerationStructureNV: result = Id::fromWord(it.word(1)); resultType = Id(); break;
case rdcspv::Op::TypeAccelerationStructureKHR: result = Id::fromWord(it.word(1)); resultType = Id(); break;
case rdcspv::Op::ExecuteCallableNV: result = Id(); resultType = Id(); break;
case rdcspv::Op::TypeCooperativeMatrixNV: result = Id::fromWord(it.word(1)); resultType = Id(); break;
case rdcspv::Op::CooperativeMatrixLoadNV: result = Id::fromWord(it.word(2)); resultType = Id::fromWord(it.word(1)); break;
@@ -2309,7 +2309,6 @@ enum class Op : uint16_t
WritePackedPrimitiveIndices4x8NV = 5299,
FetchMicroTriangleVertexPositionNV = 5300,
FetchMicroTriangleVertexBarycentricNV = 5301,
ReportIntersectionNV = 5334,
ReportIntersectionKHR = 5334,
IgnoreIntersectionNV = 5335,
TerminateRayNV = 5336,
@@ -2317,7 +2316,6 @@ enum class Op : uint16_t
TraceMotionNV = 5338,
TraceRayMotionNV = 5339,
RayQueryGetIntersectionTriangleVertexPositionsKHR = 5340,
TypeAccelerationStructureNV = 5341,
TypeAccelerationStructureKHR = 5341,
ExecuteCallableNV = 5344,
TypeCooperativeMatrixNV = 5358,
@@ -16076,14 +16076,14 @@ struct OpFetchMicroTriangleVertexBarycentricNV
Id barycentric;
};
struct OpReportIntersectionNV
struct OpReportIntersectionKHR
{
OpReportIntersectionNV(const ConstIter &it)
OpReportIntersectionKHR(const ConstIter &it)
{
memcpy(this, it.words(), sizeof(*this));
}
OpReportIntersectionNV(IdResultType resultType, IdResult result, Id hit, Id hitKind)
: op(Op::ReportIntersectionNV)
OpReportIntersectionKHR(IdResultType resultType, IdResult result, Id hit, Id hitKind)
: op(Op::ReportIntersectionKHR)
, wordCount(FixedWordSize)
{
this->resultType = resultType;
@@ -16092,7 +16092,7 @@ struct OpReportIntersectionNV
this->hitKind = hitKind;
}
static constexpr Op OpCode = Op::ReportIntersectionNV;
static constexpr Op OpCode = Op::ReportIntersectionKHR;
static constexpr uint16_t FixedWordSize = 5U;
Op op;
uint16_t wordCount;
@@ -16292,20 +16292,20 @@ struct OpRayQueryGetIntersectionTriangleVertexPositionsKHR
Id intersection;
};
struct OpTypeAccelerationStructureNV
struct OpTypeAccelerationStructureKHR
{
OpTypeAccelerationStructureNV(const ConstIter &it)
OpTypeAccelerationStructureKHR(const ConstIter &it)
{
memcpy(this, it.words(), sizeof(*this));
}
OpTypeAccelerationStructureNV(IdResult result)
: op(Op::TypeAccelerationStructureNV)
OpTypeAccelerationStructureKHR(IdResult result)
: op(Op::TypeAccelerationStructureKHR)
, wordCount(FixedWordSize)
{
this->result = result;
}
static constexpr Op OpCode = Op::TypeAccelerationStructureNV;
static constexpr Op OpCode = Op::TypeAccelerationStructureKHR;
static constexpr uint16_t FixedWordSize = 2U;
Op op;
uint16_t wordCount;