Skip to content

Commit 5bfb423

Browse files
authored
Merge pull request KhronosGroup#2367 from KhronosGroup/fix-semantic-checking
Remove incorrect style of extension-based semantic checking.
2 parents d253278 + 0138472 commit 5bfb423

14 files changed

+1449
-1435
lines changed

SPIRV/GlslangToSpv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
14441444
// Add the source extensions
14451445
const auto& sourceExtensions = glslangIntermediate->getRequestedExtensions();
14461446
for (auto it = sourceExtensions.begin(); it != sourceExtensions.end(); ++it)
1447-
builder.addSourceExtension(it->first.c_str());
1447+
builder.addSourceExtension(it->c_str());
14481448

14491449
// Add the top-level modes for this shader.
14501450

Test/baseResults/spv.bufferhandle17_Errors.frag.out

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ spv.bufferhandle17_Errors.frag
22
ERROR: 0:11: 'qualifier' : variables with reference type can't have qualifier 'const'
33
ERROR: 0:16: 'qualifier' : variables with reference type can't have qualifier 'const'
44
ERROR: 0:18: '==' : can't use with reference types
5+
ERROR: 0:18: 'buffer reference math' : required extension not requested: GL_EXT_buffer_reference2
6+
ERROR: 0:18: '==' : wrong operand types: no operation '==' exists that takes a left-hand operand of type ' temp reference' and a right operand of type ' temp reference' (or there is no acceptable conversion)
57
ERROR: 0:19: '!=' : can't use with reference types
6-
ERROR: 4 compilation errors. No code generated.
8+
ERROR: 0:19: 'buffer reference math' : required extension not requested: GL_EXT_buffer_reference2
9+
ERROR: 0:19: '!=' : wrong operand types: no operation '!=' exists that takes a left-hand operand of type ' temp reference' and a right operand of type ' temp reference' (or there is no acceptable conversion)
10+
ERROR: 8 compilation errors. No code generated.
711

812

913
SPIR-V is not generated for failed compile or link

Test/baseResults/versionsErrors.frag.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ ERROR: 4 compilation errors. No code generated.
77

88

99
Shader version: 110
10-
Requested GL_ARB_texture_rectangle
1110
ERROR: node is still EOpNull!
1211
0:42 Function Definition: main( ( global void)
1312
0:42 Function Parameters:
@@ -28,7 +27,6 @@ Linked fragment stage:
2827

2928

3029
Shader version: 110
31-
Requested GL_ARB_texture_rectangle
3230
ERROR: node is still EOpNull!
3331
0:42 Function Definition: main( ( global void)
3432
0:42 Function Parameters:

glslang/MachineIndependent/Intermediate.cpp

Lines changed: 142 additions & 178 deletions
Large diffs are not rendered by default.

glslang/MachineIndependent/ParseHelper.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,11 @@ TIntermTyped* TParseContext::handleBinaryMath(const TSourceLoc& loc, const char*
751751
}
752752

753753
TIntermTyped* result = nullptr;
754-
if (allowed)
754+
if (allowed) {
755+
if ((left->isReference() || right->isReference()))
756+
requireExtensions(loc, 1, &E_GL_EXT_buffer_reference2, "buffer reference math");
755757
result = intermediate.addBinaryMath(op, left, right, loc);
758+
}
756759

757760
if (result == nullptr)
758761
binaryOpError(loc, str, left->getCompleteString(), right->getCompleteString());
@@ -1680,6 +1683,14 @@ TIntermTyped* TParseContext::addOutputArgumentConversions(const TFunction& funct
16801683
#endif
16811684
}
16821685

1686+
TIntermTyped* TParseContext::addAssign(const TSourceLoc& loc, TOperator op, TIntermTyped* left, TIntermTyped* right)
1687+
{
1688+
if ((op == EOpAddAssign || op == EOpSubAssign) && left->isReference())
1689+
requireExtensions(loc, 1, &E_GL_EXT_buffer_reference2, "+= and -= on a buffer reference");
1690+
1691+
return intermediate.addAssign(op, left, right, loc);
1692+
}
1693+
16831694
void TParseContext::memorySemanticsCheck(const TSourceLoc& loc, const TFunction& fnCandidate, const TIntermOperator& callNode)
16841695
{
16851696
const TIntermSequence* argp = &callNode.getAsAggregate()->getSequence();
@@ -7305,6 +7316,8 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
73057316
if (!node->getType().isCoopMat()) {
73067317
if (type.getBasicType() != node->getType().getBasicType()) {
73077318
node = intermediate.addConversion(type.getBasicType(), node);
7319+
if (node == nullptr)
7320+
return nullptr;
73087321
}
73097322
node = intermediate.setAggregateOperator(node, EOpConstructCooperativeMatrix, type, node->getLoc());
73107323
} else {

glslang/MachineIndependent/ParseHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class TParseContext : public TParseContextBase {
328328
TIntermTyped* handleLengthMethod(const TSourceLoc&, TFunction*, TIntermNode*);
329329
void addInputArgumentConversions(const TFunction&, TIntermNode*&) const;
330330
TIntermTyped* addOutputArgumentConversions(const TFunction&, TIntermAggregate&) const;
331+
TIntermTyped* addAssign(const TSourceLoc&, TOperator op, TIntermTyped* left, TIntermTyped* right);
331332
void builtInOpCheck(const TSourceLoc&, const TFunction&, TIntermOperator&);
332333
void nonOpBuiltInCheck(const TSourceLoc&, const TFunction&, TIntermAggregate&);
333334
void userFunctionCallCheck(const TSourceLoc&, TIntermAggregate&);

glslang/MachineIndependent/Versions.cpp

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,8 @@ bool TParseVersions::checkExtensionsRequested(const TSourceLoc& loc, int numExte
762762
// Use when there are no profile/version to check, it's just an error if one of the
763763
// extensions is not present.
764764
//
765-
void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
765+
void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[],
766+
const char* featureDesc)
766767
{
767768
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
768769
return;
@@ -781,7 +782,8 @@ void TParseVersions::requireExtensions(const TSourceLoc& loc, int numExtensions,
781782
// Use by preprocessor when there are no profile/version to check, it's just an error if one of the
782783
// extensions is not present.
783784
//
784-
void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[], const char* featureDesc)
785+
void TParseVersions::ppRequireExtensions(const TSourceLoc& loc, int numExtensions, const char* const extensions[],
786+
const char* featureDesc)
785787
{
786788
if (checkExtensionsRequested(loc, numExtensions, extensions, featureDesc))
787789
return;
@@ -847,6 +849,7 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
847849
error(getCurrentLoc(), "behavior not supported:", "#extension", behaviorString);
848850
return;
849851
}
852+
bool on = behavior != EBhDisable;
850853

851854
// check if extension is used with correct shader stage
852855
checkExtensionStage(getCurrentLoc(), extension);
@@ -916,6 +919,32 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
916919
updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_int64", behaviorString);
917920
else if (strcmp(extension, "GL_EXT_shader_subgroup_extended_types_float16") == 0)
918921
updateExtensionBehavior(line, "GL_EXT_shader_explicit_arithmetic_types_float16", behaviorString);
922+
923+
// see if we need to update the numeric features
924+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types") == 0)
925+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types, on);
926+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int8") == 0)
927+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int8, on);
928+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int16") == 0)
929+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int16, on);
930+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int32") == 0)
931+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int32, on);
932+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_int64") == 0)
933+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_int64, on);
934+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float16") == 0)
935+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float16, on);
936+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float32") == 0)
937+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float32, on);
938+
else if (strcmp(extension, "GL_EXT_shader_explicit_arithmetic_types_float64") == 0)
939+
intermediate.updateNumericFeature(TNumericFeatures::shader_explicit_arithmetic_types_float64, on);
940+
else if (strcmp(extension, "GL_EXT_shader_implicit_conversions") == 0)
941+
intermediate.updateNumericFeature(TNumericFeatures::shader_implicit_conversions, on);
942+
else if (strcmp(extension, "GL_ARB_gpu_shader_fp64") == 0)
943+
intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_fp64, on);
944+
else if (strcmp(extension, "GL_AMD_gpu_shader_int16") == 0)
945+
intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_int16, on);
946+
else if (strcmp(extension, "GL_AMD_gpu_shader_half_float") == 0)
947+
intermediate.updateNumericFeature(TNumericFeatures::gpu_shader_half_float, on);
919948
}
920949

921950
void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBehavior behavior)
@@ -951,8 +980,8 @@ void TParseVersions::updateExtensionBehavior(const char* extension, TExtensionBe
951980
} else {
952981
if (iter->second == EBhDisablePartial)
953982
warn(getCurrentLoc(), "extension is only partially supported:", "#extension", extension);
954-
if (behavior == EBhEnable || behavior == EBhRequire || behavior == EBhDisable)
955-
intermediate.updateRequestedExtension(extension, behavior);
983+
if (behavior != EBhDisable)
984+
intermediate.addRequestedExtension(extension);
956985
iter->second = behavior;
957986
}
958987
}

glslang/MachineIndependent/glslang.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ assignment_expression
778778
parseContext.specializationCheck($2.loc, $1->getType(), "=");
779779
parseContext.lValueErrorCheck($2.loc, "assign", $1);
780780
parseContext.rValueErrorCheck($2.loc, "assign", $3);
781-
$$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.loc);
781+
$$ = parseContext.addAssign($2.loc, $2.op, $1, $3);
782782
if ($$ == 0) {
783783
parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
784784
$$ = $1;

glslang/MachineIndependent/glslang.y

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ assignment_expression
778778
parseContext.specializationCheck($2.loc, $1->getType(), "=");
779779
parseContext.lValueErrorCheck($2.loc, "assign", $1);
780780
parseContext.rValueErrorCheck($2.loc, "assign", $3);
781-
$$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.loc);
781+
$$ = parseContext.addAssign($2.loc, $2.op, $1, $3);
782782
if ($$ == 0) {
783783
parseContext.assignError($2.loc, "assign", $1->getCompleteString(), $3->getCompleteString());
784784
$$ = $1;
@@ -3885,4 +3885,3 @@ single_attribute
38853885

38863886

38873887
%%
3888-

0 commit comments

Comments
 (0)