Spirv_intrinsics: Remove early return in layoutTypeCheck

Previously, when GL_EXT_spirv_intrinsics are enabled, we disable all
checks in layoutTypeCheck. This is too coarse because we can use nothing
in GL_EXT_spirv_intrinsics in a shader while the necessary processing is
skipped, such as addUsedLocation.

In this change, we apply fine check and more might be added if we
encounter new cases in the future.
This commit is contained in:
Rex Xu 2023-07-05 14:44:40 +08:00 committed by kd-11
parent e69f74f010
commit 0da98c51c4
4 changed files with 19 additions and 4 deletions

View File

@ -0,0 +1,6 @@
spv.intrinsicsFakeEnable.vert
ERROR: 0:7: 'location' : overlapping use of location 0
ERROR: 1 compilation errors. No code generated.
SPIR-V is not generated for failed compile or link

View File

@ -0,0 +1,10 @@
#version 460 core
#extension GL_EXT_spirv_intrinsics : enable
// ERROR: Overlapped input location. Make sure it could be detected even
// if GL_EXT_spirv_intrinsics is enabled.
layout(location = 0) in vec4 v4;
layout(location = 0) in vec3 v3;
void main() {
}

View File

@ -6324,9 +6324,6 @@ void TParseContext::layoutMemberLocationArrayCheck(const TSourceLoc& loc, bool m
// Do layout error checking with respect to a type. // Do layout error checking with respect to a type.
void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type) void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
{ {
if (extensionTurnedOn(E_GL_EXT_spirv_intrinsics))
return; // Skip any check if GL_EXT_spirv_intrinsics is turned on
const TQualifier& qualifier = type.getQualifier(); const TQualifier& qualifier = type.getQualifier();
// first, intra-layout qualifier-only error checking // first, intra-layout qualifier-only error checking
@ -6380,6 +6377,7 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
case EvqCallableData: case EvqCallableData:
case EvqCallableDataIn: case EvqCallableDataIn:
case EvqHitObjectAttrNV: case EvqHitObjectAttrNV:
case EvqSpirvStorageClass:
break; break;
case EvqTileImageEXT: case EvqTileImageEXT:
break; break;
@ -6436,7 +6434,7 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
// an array of size N, all elements of the array from binding through binding + N - 1 must be within this // an array of size N, all elements of the array from binding through binding + N - 1 must be within this
// range." // range."
// //
if (! type.isOpaque() && type.getBasicType() != EbtBlock) if (!type.isOpaque() && type.getBasicType() != EbtBlock && type.getBasicType() != EbtSpirvType)
error(loc, "requires block, or sampler/image, or atomic-counter type", "binding", ""); error(loc, "requires block, or sampler/image, or atomic-counter type", "binding", "");
if (type.getBasicType() == EbtSampler) { if (type.getBasicType() == EbtSampler) {
int lastBinding = qualifier.layoutBinding; int lastBinding = qualifier.layoutBinding;

View File

@ -757,6 +757,7 @@ INSTANTIATE_TEST_SUITE_P(
"vulkan.vert", "vulkan.vert",
"vulkan.comp", "vulkan.comp",
"samplerlessTextureFunctions.frag", "samplerlessTextureFunctions.frag",
"spv.intrinsicsFakeEnable.vert",
"spv.specConstArrayCheck.vert", "spv.specConstArrayCheck.vert",
})), })),
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix