GLSL: Add version-number checking.

This commit is contained in:
John Kessenich 2017-07-23 11:49:42 -06:00
parent 67eb497002
commit 9353f1afab
4 changed files with 66 additions and 3 deletions

2
Test/435.vert Normal file
View File

@ -0,0 +1,2 @@
#version 435
void main() {}

25
Test/baseResults/435.vert.out Executable file
View File

@ -0,0 +1,25 @@
435.vert
ERROR: version not supported
ERROR: 1 compilation errors. No code generated.
Shader version: 450
ERROR: node is still EOpNull!
0:2 Function Definition: main( ( global void)
0:2 Function Parameters:
0:? Linker Objects
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
Linked vertex stage:
Shader version: 450
ERROR: node is still EOpNull!
0:2 Function Definition: main( ( global void)
0:2 Function Parameters:
0:? Linker Objects
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

View File

@ -1,7 +1,7 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// Copyright (C) 2013-2016 LunarG, Inc.
// Copyright (C) 2015-2016 Google, Inc.
// Copyright (C) 2015-2017 Google, Inc.
//
// All rights reserved.
//
@ -138,7 +138,8 @@ int MapVersionToIndex(int version)
case 440: index = 12; break;
case 310: index = 13; break;
case 450: index = 14; break;
default: break;
case 500: index = 0; break; // HLSL
default: assert(0); break;
}
assert(index < VersionCount);
@ -447,7 +448,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
return correct;
}
// Get a good version...
// Get a version...
if (version == 0) {
version = defaultVersion;
// infoSink.info.message(EPrefixWarning, "#version: statement missing; use #version on first line of shader");
@ -493,6 +494,40 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
}
}
// Fix version...
switch (version) {
// ES versions
case 100: break;
case 300: break;
case 310: break;
// desktop versions
case 110: break;
case 120: break;
case 130: break;
case 140: break;
case 150: break;
case 330: break;
case 400: break;
case 410: break;
case 420: break;
case 430: break;
case 440: break;
case 450: break;
// unknown version
default:
correct = false;
infoSink.info.message(EPrefixError, "version not supported");
if (profile == EEsProfile)
version = 310;
else {
version = 450;
profile = ECoreProfile;
}
break;
}
// Correct for stage type...
switch (stage) {
case EShLangGeometry:

View File

@ -136,6 +136,7 @@ INSTANTIATE_TEST_CASE_P(
"430.vert",
"430.comp",
"430AofA.frag",
"435.vert",
"440.vert",
"440.frag",
"450.vert",