Spirv_intrinsics: Add support of type specifier to spirv_type
Previously, spirv_type doesn't accept type specifier as its parameter. With this change, we can input non-array type specifier. This is because some SPIR-V type definition intructions often need to reference other SPIR-V types as its source operands. We add the support to facilitate such usage.
This commit is contained in:
parent
eaa7057768
commit
051f18c0cc
10 changed files with 1468 additions and 1359 deletions
|
|
@ -486,6 +486,7 @@ public:
|
|||
TSpirvRequirement* mergeSpirvRequirements(const TSourceLoc& loc, TSpirvRequirement* spirvReq1,
|
||||
TSpirvRequirement* spirvReq2);
|
||||
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TIntermConstantUnion* constant);
|
||||
TSpirvTypeParameters* makeSpirvTypeParameters(const TSourceLoc& loc, const TPublicType& type);
|
||||
TSpirvTypeParameters* mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1,
|
||||
TSpirvTypeParameters* spirvTypeParams2);
|
||||
TSpirvInstruction* makeSpirvInstruction(const TSourceLoc& loc, const TString& name, const TString& value);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,15 @@
|
|||
|
||||
namespace glslang {
|
||||
|
||||
bool TSpirvTypeParameter::operator==(const TSpirvTypeParameter& rhs) const
|
||||
{
|
||||
if (constant != nullptr)
|
||||
return constant->getConstArray() == rhs.constant->getConstArray();
|
||||
|
||||
assert(type != nullptr);
|
||||
return *type == *rhs.type;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle SPIR-V requirements
|
||||
//
|
||||
|
|
@ -283,14 +292,19 @@ TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& l
|
|||
constant->getBasicType() != EbtBool &&
|
||||
constant->getBasicType() != EbtString)
|
||||
error(loc, "this type not allowed", constant->getType().getBasicString(), "");
|
||||
else {
|
||||
assert(constant);
|
||||
else
|
||||
spirvTypeParams->push_back(TSpirvTypeParameter(constant));
|
||||
}
|
||||
|
||||
return spirvTypeParams;
|
||||
}
|
||||
|
||||
TSpirvTypeParameters* TParseContext::makeSpirvTypeParameters(const TSourceLoc& loc, const TPublicType& type)
|
||||
{
|
||||
TSpirvTypeParameters* spirvTypeParams = new TSpirvTypeParameters;
|
||||
spirvTypeParams->push_back(TSpirvTypeParameter(new TType(type)));
|
||||
return spirvTypeParams;
|
||||
}
|
||||
|
||||
TSpirvTypeParameters* TParseContext::mergeSpirvTypeParameters(TSpirvTypeParameters* spirvTypeParams1, TSpirvTypeParameters* spirvTypeParams2)
|
||||
{
|
||||
// Merge SPIR-V type parameters of the second one to the first one
|
||||
|
|
|
|||
|
|
@ -4439,6 +4439,9 @@ spirv_type_parameter
|
|||
: constant_expression {
|
||||
$$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
|
||||
}
|
||||
| type_specifier_nonarray {
|
||||
$$ = parseContext.makeSpirvTypeParameters($1.loc, $1);
|
||||
}
|
||||
|
||||
spirv_instruction_qualifier
|
||||
: SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {
|
||||
|
|
|
|||
|
|
@ -4439,6 +4439,9 @@ spirv_type_parameter
|
|||
: constant_expression {
|
||||
$$ = parseContext.makeSpirvTypeParameters($1->getLoc(), $1->getAsConstantUnion());
|
||||
}
|
||||
| type_specifier_nonarray {
|
||||
$$ = parseContext.makeSpirvTypeParameters($1.loc, $1);
|
||||
}
|
||||
|
||||
spirv_instruction_qualifier
|
||||
: SPIRV_INSTRUCTION LEFT_PAREN spirv_instruction_qualifier_list RIGHT_PAREN {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue