ESSL/SPV: Fix #1856: Allow ESSL shaders to compile to OpenGL SPIR-V.

This commit is contained in:
John Kessenich 2019-08-28 02:51:38 -06:00
parent efd47a8fae
commit df1d4ccf5f
4 changed files with 28 additions and 14 deletions

View File

@ -293,7 +293,7 @@ class TProgram
For just validating (not generating code), subsitute these calls:
```
```cxx
setEnvInput(EShSourceHlsl or EShSourceGlsl, stage, EShClientNone, 0);
setEnvClient(EShClientNone, 0);
setEnvTarget(EShTargetNone, 0);

View File

@ -1,6 +1,25 @@
glspv.esversion.vert
ERROR: #version: ES shaders for OpenGL SPIR-V are not supported
ERROR: 1 compilation errors. No code generated.
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 10
SPIR-V is not generated for failed compile or link
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 8 9
Source ESSL 310
Name 4 "main"
Name 8 "gl_VertexID"
Name 9 "gl_InstanceID"
Decorate 8(gl_VertexID) BuiltIn VertexId
Decorate 9(gl_InstanceID) BuiltIn InstanceId
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Input 6(int)
8(gl_VertexID): 7(ptr) Variable Input
9(gl_InstanceID): 7(ptr) Variable Input
4(main): 2 Function None 3
5: Label
Return
FunctionEnd

View File

@ -646,14 +646,9 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
if (spvVersion.spv != 0) {
switch (profile) {
case EEsProfile:
if (spvVersion.vulkan > 0 && version < 310) {
if (version < 310) {
correct = false;
infoSink.info.message(EPrefixError, "#version: ES shaders for Vulkan SPIR-V require version 310 or higher");
version = 310;
}
if (spvVersion.openGl >= 100) {
correct = false;
infoSink.info.message(EPrefixError, "#version: ES shaders for OpenGL SPIR-V are not supported");
infoSink.info.message(EPrefixError, "#version: ES shaders for SPIR-V require version 310 or higher");
version = 310;
}
break;

View File

@ -126,8 +126,8 @@ class TType;
typedef enum {
EShSourceNone,
EShSourceGlsl,
EShSourceHlsl,
EShSourceGlsl, // GLSL, includes ESSL (OpenGL ES GLSL)
EShSourceHlsl, // HLSL
} EShSource; // if EShLanguage were EShStage, this could be EShLanguage instead
typedef enum {