Add a string 'StartsWith' helper function

This commit is contained in:
Jeff Bolz 2024-02-14 17:02:45 -06:00 committed by arcady-lunarg
parent 48702616ec
commit 114dae9114
2 changed files with 15 additions and 10 deletions

View file

@ -159,6 +159,11 @@ template<class T> inline T* NewPoolObject(T, int instances)
return new(GetThreadPoolAllocator().allocate(instances * sizeof(T))) T[instances]; return new(GetThreadPoolAllocator().allocate(instances * sizeof(T))) T[instances];
} }
inline bool StartsWith(TString const &str, const char *prefix)
{
return str.compare(0, strlen(prefix), prefix) == 0;
}
// //
// Pool allocator versions of vectors, lists, and maps // Pool allocator versions of vectors, lists, and maps
// //

View file

@ -2527,23 +2527,23 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
} else if(callNode.getType().getBasicType() == EbtFloat16 && } else if(callNode.getType().getBasicType() == EbtFloat16 &&
((callNode.getType().getVectorSize() == 2 && arg0->getType().getQualifier().getFormat() == ElfRg16f) || ((callNode.getType().getVectorSize() == 2 && arg0->getType().getQualifier().getFormat() == ElfRg16f) ||
(callNode.getType().getVectorSize() == 4 && arg0->getType().getQualifier().getFormat() == ElfRgba16f))) { (callNode.getType().getVectorSize() == 4 && arg0->getType().getQualifier().getFormat() == ElfRgba16f))) {
if ((fnCandidate.getName().compare(0, 14, "imageAtomicAdd") == 0) || if (StartsWith(fnCandidate.getName(), "imageAtomicAdd") ||
(fnCandidate.getName().compare(0, 19, "imageAtomicExchange") == 0) || StartsWith(fnCandidate.getName(), "imageAtomicExchange") ||
(fnCandidate.getName().compare(0, 19, "imageAtomicMin") == 0) || StartsWith(fnCandidate.getName(), "imageAtomicMin") ||
(fnCandidate.getName().compare(0, 19, "imageAtomicMax") == 0)) { StartsWith(fnCandidate.getName(), "imageAtomicMax")) {
requireExtensions(loc, 1, &E_GL_NV_shader_atomic_fp16_vector, fnCandidate.getName().c_str()); requireExtensions(loc, 1, &E_GL_NV_shader_atomic_fp16_vector, fnCandidate.getName().c_str());
} else { } else {
error(loc, "f16vec2/4 operation not supported on: ", fnCandidate.getName().c_str(), ""); error(loc, "f16vec2/4 operation not supported on: ", fnCandidate.getName().c_str(), "");
} }
} else if (imageType.getSampler().type == EbtFloat) { } else if (imageType.getSampler().type == EbtFloat) {
if (fnCandidate.getName().compare(0, 19, "imageAtomicExchange") == 0) { if (StartsWith(fnCandidate.getName(), "imageAtomicExchange")) {
// imageAtomicExchange doesn't require an extension // imageAtomicExchange doesn't require an extension
} else if ((fnCandidate.getName().compare(0, 14, "imageAtomicAdd") == 0) || } else if (StartsWith(fnCandidate.getName(), "imageAtomicAdd") ||
(fnCandidate.getName().compare(0, 15, "imageAtomicLoad") == 0) || StartsWith(fnCandidate.getName(), "imageAtomicLoad") ||
(fnCandidate.getName().compare(0, 16, "imageAtomicStore") == 0)) { StartsWith(fnCandidate.getName(), "imageAtomicStore")) {
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str()); requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float, fnCandidate.getName().c_str());
} else if ((fnCandidate.getName().compare(0, 14, "imageAtomicMin") == 0) || } else if (StartsWith(fnCandidate.getName(), "imageAtomicMin") ||
(fnCandidate.getName().compare(0, 14, "imageAtomicMax") == 0)) { StartsWith(fnCandidate.getName(), "imageAtomicMax")) {
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str()); requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_float2, fnCandidate.getName().c_str());
} else { } else {
error(loc, "only supported on integer images", fnCandidate.getName().c_str(), ""); error(loc, "only supported on integer images", fnCandidate.getName().c_str(), "");