From ea543986f9dbc8224ab50b69d8258101a325b1b1 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Fri, 22 May 2015 01:21:31 +0000 Subject: [PATCH] glslang -> SPV: translate the source profile to the SPV source language. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31265 e7fa87d3-cd2b-0410-9028-fcbf551c1848 --- SPIRV/GlslangToSpv.cpp | 17 ++++++++++++++++- Test/baseResults/spv.100ops.frag.out | 2 +- Test/baseResults/spv.300BuiltIns.vert.out | 2 +- Test/baseResults/spv.300layout.frag.out | 2 +- Test/baseResults/spv.300layoutp.vert.out | 2 +- Test/baseResults/spv.do-simple.vert.out | 2 +- Test/baseResults/spv.do-while-continue-break.vert.out | 2 +- Test/baseResults/spv.for-continue-break.vert.out | 2 +- Test/baseResults/spv.for-simple.vert.out | 2 +- Test/baseResults/spv.forwardFun.frag.out | 2 +- Test/baseResults/spv.precision.frag.out | 2 +- Test/baseResults/spv.switch.frag.out | 2 +- Test/baseResults/spv.uint.frag.out | 2 +- Test/baseResults/spv.while-continue-break.vert.out | 2 +- Test/baseResults/spv.while-simple.vert.out | 2 +- 15 files changed, 30 insertions(+), 15 deletions(-) diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp index 08526cb..3ddc7b2 100644 --- a/SPIRV/GlslangToSpv.cpp +++ b/SPIRV/GlslangToSpv.cpp @@ -130,6 +130,21 @@ protected: // Helper functions for translating glslang representations to SPIR-V enumerants. // +// Translate glslang profile to SPIR-V source language. +spv::SourceLanguage TranslateSourceLanguage(EProfile profile) +{ + switch (profile) { + case ENoProfile: + case ECoreProfile: + case ECompatibilityProfile: + return spv::SourceLanguageGLSL; + case EEsProfile: + return spv::SourceLanguageESSL; + default: + return spv::SourceLanguageUnknown; + } +} + // Translate glslang language (stage) to SPIR-V execution model. spv::ExecutionModel TranslateExecutionModel(EShLanguage stage) { @@ -339,7 +354,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage()); builder.clearAccessChain(); - builder.setSource(spv::SourceLanguageGLSL, glslangIntermediate->getVersion()); + builder.setSource(TranslateSourceLanguage(glslangIntermediate->getProfile()), glslangIntermediate->getVersion()); stdBuiltins = builder.import("GLSL.std.450"); builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450); shaderEntry = builder.makeMain(); diff --git a/Test/baseResults/spv.100ops.frag.out b/Test/baseResults/spv.100ops.frag.out index d000faa..f07782c 100644 --- a/Test/baseResults/spv.100ops.frag.out +++ b/Test/baseResults/spv.100ops.frag.out @@ -10,7 +10,7 @@ Linked fragment stage: // Generated by (magic number): 51a00bb // Id's are bound by 48 - Source GLSL 100 + Source ESSL 100 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 4 diff --git a/Test/baseResults/spv.300BuiltIns.vert.out b/Test/baseResults/spv.300BuiltIns.vert.out index 9ec134f..13edf06 100644 --- a/Test/baseResults/spv.300BuiltIns.vert.out +++ b/Test/baseResults/spv.300BuiltIns.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 41 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.300layout.frag.out b/Test/baseResults/spv.300layout.frag.out index d81baf1..5e2f699 100644 --- a/Test/baseResults/spv.300layout.frag.out +++ b/Test/baseResults/spv.300layout.frag.out @@ -10,7 +10,7 @@ Linked fragment stage: // Generated by (magic number): 51a00bb // Id's are bound by 38 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 4 diff --git a/Test/baseResults/spv.300layoutp.vert.out b/Test/baseResults/spv.300layoutp.vert.out index 6c8697b..c7d9882 100644 --- a/Test/baseResults/spv.300layoutp.vert.out +++ b/Test/baseResults/spv.300layoutp.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 112 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.do-simple.vert.out b/Test/baseResults/spv.do-simple.vert.out index 668d4c4..e376b82 100644 --- a/Test/baseResults/spv.do-simple.vert.out +++ b/Test/baseResults/spv.do-simple.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 26 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.do-while-continue-break.vert.out b/Test/baseResults/spv.do-while-continue-break.vert.out index e6c6ef1..e9d4526 100644 --- a/Test/baseResults/spv.do-while-continue-break.vert.out +++ b/Test/baseResults/spv.do-while-continue-break.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 48 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.for-continue-break.vert.out b/Test/baseResults/spv.for-continue-break.vert.out index 60b147c..8df0a08 100644 --- a/Test/baseResults/spv.for-continue-break.vert.out +++ b/Test/baseResults/spv.for-continue-break.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 49 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.for-simple.vert.out b/Test/baseResults/spv.for-simple.vert.out index 6dc1824..180805a 100644 --- a/Test/baseResults/spv.for-simple.vert.out +++ b/Test/baseResults/spv.for-simple.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 26 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.forwardFun.frag.out b/Test/baseResults/spv.forwardFun.frag.out index 23f8e53..2be58e1 100644 --- a/Test/baseResults/spv.forwardFun.frag.out +++ b/Test/baseResults/spv.forwardFun.frag.out @@ -10,7 +10,7 @@ Linked fragment stage: // Generated by (magic number): 51a00bb // Id's are bound by 59 - Source GLSL 100 + Source ESSL 100 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 4 diff --git a/Test/baseResults/spv.precision.frag.out b/Test/baseResults/spv.precision.frag.out index 71abeeb..5ba1a5f 100644 --- a/Test/baseResults/spv.precision.frag.out +++ b/Test/baseResults/spv.precision.frag.out @@ -10,7 +10,7 @@ Linked fragment stage: // Generated by (magic number): 51a00bb // Id's are bound by 111 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 4 diff --git a/Test/baseResults/spv.switch.frag.out b/Test/baseResults/spv.switch.frag.out index 68a102f..10a7705 100644 --- a/Test/baseResults/spv.switch.frag.out +++ b/Test/baseResults/spv.switch.frag.out @@ -11,7 +11,7 @@ Linked fragment stage: // Generated by (magic number): 51a00bb // Id's are bound by 249 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 4 diff --git a/Test/baseResults/spv.uint.frag.out b/Test/baseResults/spv.uint.frag.out index 751294d..eb7f4ad 100644 --- a/Test/baseResults/spv.uint.frag.out +++ b/Test/baseResults/spv.uint.frag.out @@ -10,7 +10,7 @@ Linked fragment stage: // Generated by (magic number): 51a00bb // Id's are bound by 206 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Fragment 4 diff --git a/Test/baseResults/spv.while-continue-break.vert.out b/Test/baseResults/spv.while-continue-break.vert.out index f072ab7..9d4d3bb 100644 --- a/Test/baseResults/spv.while-continue-break.vert.out +++ b/Test/baseResults/spv.while-continue-break.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 43 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 diff --git a/Test/baseResults/spv.while-simple.vert.out b/Test/baseResults/spv.while-simple.vert.out index 584afab..8f35aa1 100644 --- a/Test/baseResults/spv.while-simple.vert.out +++ b/Test/baseResults/spv.while-simple.vert.out @@ -10,7 +10,7 @@ Linked vertex stage: // Generated by (magic number): 51a00bb // Id's are bound by 24 - Source GLSL 300 + Source ESSL 300 1: ExtInstImport "GLSL.std.450" MemoryModel Logical GLSL450 EntryPoint Vertex 4 -- 2.7.4