Merge pull request #1542 from sheredom/fix_8bit_storagebuffer
Fix 8-bit storage nearly always using the UniformAndStorageBuffer8BitAccess capability.
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
old mode 100644
new mode 100755
index b3f7df7..21a8c0c
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -1265,14 +1265,14 @@
std::string text;
const std::vector<std::string>& processes = glslangIntermediate->getProcesses();
for (int p = 0; p < (int)processes.size(); ++p) {
- if (glslangIntermediate->getSpv().spv < 0x00010100) {
+ if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1) {
text.append("// OpModuleProcessed ");
text.append(processes[p]);
text.append("\n");
} else
builder.addModuleProcessed(processes[p]);
}
- if (glslangIntermediate->getSpv().spv < 0x00010100 && (int)processes.size() > 0)
+ if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1 && (int)processes.size() > 0)
text.append("#line 1\n");
text.append(glslangIntermediate->getSourceText());
builder.setSourceText(text);
@@ -7203,15 +7203,29 @@
void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier& qualifier)
{
if (member >= 0) {
- if (qualifier.perPrimitiveNV)
+ if (qualifier.perPrimitiveNV) {
+ // Need to add capability/extension for fragment shader.
+ // Mesh shader already adds this by default.
+ if (glslangIntermediate->getStage() == EShLangFragment) {
+ builder.addCapability(spv::CapabilityMeshShadingNV);
+ builder.addExtension(spv::E_SPV_NV_mesh_shader);
+ }
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerPrimitiveNV);
+ }
if (qualifier.perViewNV)
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerViewNV);
if (qualifier.perTaskNV)
builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerTaskNV);
} else {
- if (qualifier.perPrimitiveNV)
+ if (qualifier.perPrimitiveNV) {
+ // Need to add capability/extension for fragment shader.
+ // Mesh shader already adds this by default.
+ if (glslangIntermediate->getStage() == EShLangFragment) {
+ builder.addCapability(spv::CapabilityMeshShadingNV);
+ builder.addExtension(spv::E_SPV_NV_mesh_shader);
+ }
builder.addDecoration(id, spv::DecorationPerPrimitiveNV);
+ }
if (qualifier.perViewNV)
builder.addDecoration(id, spv::DecorationPerViewNV);
if (qualifier.perTaskNV)
diff --git a/SPIRV/SpvPostProcess.cpp b/SPIRV/SpvPostProcess.cpp
index 27f145d..3193ac9 100755
--- a/SPIRV/SpvPostProcess.cpp
+++ b/SPIRV/SpvPostProcess.cpp
@@ -208,7 +208,7 @@
}
// Called for each instruction in a reachable block.
-void Builder::postProcessReachable(const Instruction& inst)
+void Builder::postProcessReachable(const Instruction&)
{
// did have code here, but questionable to do so without deleting the instructions
}
diff --git a/SPIRV/SpvTools.cpp b/SPIRV/SpvTools.cpp
index 4807b42..bc9bf9e 100755
--- a/SPIRV/SpvTools.cpp
+++ b/SPIRV/SpvTools.cpp
@@ -114,8 +114,8 @@
// Apply the SPIRV-Tools optimizer to generated SPIR-V, for the purpose of
// legalizing HLSL SPIR-V.
-void SpirvToolsLegalize(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,
- spv::SpvBuildLogger* logger, const SpvOptions* options)
+void SpirvToolsLegalize(const glslang::TIntermediate&, std::vector<unsigned int>& spirv,
+ spv::SpvBuildLogger*, const SpvOptions* options)
{
spv_target_env target_env = SPV_ENV_UNIVERSAL_1_2;
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
old mode 100644
new mode 100755
index f60ffaa..060428b
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -161,13 +161,17 @@
const char* variableName = nullptr;
bool HlslEnable16BitTypes = false;
std::vector<std::string> IncludeDirectoryList;
-int ClientInputSemanticsVersion = 100; // maps to, say, #define VULKAN 100
-glslang::EShTargetClientVersion VulkanClientVersion =
- glslang::EShTargetVulkan_1_0; // would map to, say, Vulkan 1.0
-glslang::EShTargetClientVersion OpenGLClientVersion =
- glslang::EShTargetOpenGL_450; // doesn't influence anything yet, but maps to OpenGL 4.50
-glslang::EShTargetLanguageVersion TargetVersion =
- glslang::EShTargetSpv_1_0; // maps to, say, SPIR-V 1.0
+
+// Source environment
+// (source 'Client' is currently the same as target 'Client')
+int ClientInputSemanticsVersion = 100;
+
+// Target environment
+glslang::EShClient Client = glslang::EShClientNone; // will stay EShClientNone if only validating
+glslang::EShTargetClientVersion ClientVersion; // not valid until Client is set
+glslang::EShTargetLanguage TargetLanguage = glslang::EShTargetNone;
+glslang::EShTargetLanguageVersion TargetVersion; // not valid until TargetLanguage is set
+
std::vector<std::string> Processes; // what should be recorded by OpModuleProcessed, or equivalent
// Per descriptor-set binding base data
@@ -421,6 +425,9 @@
// minimum needed (without overriding something else) to target Vulkan SPIR-V
const auto setVulkanSpv = []() {
+ if (Client == glslang::EShClientNone)
+ ClientVersion = glslang::EShTargetVulkan_1_0;
+ Client = glslang::EShClientVulkan;
Options |= EOptionSpv;
Options |= EOptionVulkanRules;
Options |= EOptionLinkProgram;
@@ -428,6 +435,9 @@
// minimum needed (without overriding something else) to target OpenGL SPIR-V
const auto setOpenGlSpv = []() {
+ if (Client == glslang::EShClientNone)
+ ClientVersion = glslang::EShTargetOpenGL_450;
+ Client = glslang::EShClientOpenGL;
Options |= EOptionSpv;
Options |= EOptionLinkProgram;
// undo a -H default to Vulkan
@@ -561,16 +571,30 @@
if (argc > 1) {
if (strcmp(argv[1], "vulkan1.0") == 0) {
setVulkanSpv();
- VulkanClientVersion = glslang::EShTargetVulkan_1_0;
+ ClientVersion = glslang::EShTargetVulkan_1_0;
} else if (strcmp(argv[1], "vulkan1.1") == 0) {
setVulkanSpv();
- TargetVersion = glslang::EShTargetSpv_1_3;
- VulkanClientVersion = glslang::EShTargetVulkan_1_1;
+ ClientVersion = glslang::EShTargetVulkan_1_1;
} else if (strcmp(argv[1], "opengl") == 0) {
setOpenGlSpv();
- OpenGLClientVersion = glslang::EShTargetOpenGL_450;
+ ClientVersion = glslang::EShTargetOpenGL_450;
+ } else if (strcmp(argv[1], "spirv1.0") == 0) {
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_0;
+ } else if (strcmp(argv[1], "spirv1.1") == 0) {
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_1;
+ } else if (strcmp(argv[1], "spirv1.2") == 0) {
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_2;
+ } else if (strcmp(argv[1], "spirv1.3") == 0) {
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_3;
+ } else if (strcmp(argv[1], "spirv1.4") == 0) {
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_4;
} else
- Error("--target-env expected vulkan1.0, vulkan1.1, or opengl");
+ Error("--target-env expected one of: vulkan1.0, vulkan1.1, opengl, spirv1.0, spirv1.1, spirv1.2, or spirv1.3");
}
bumpArg();
} else if (lowerword == "variable-name" || // synonyms
@@ -604,7 +628,7 @@
Options |= EOptionOutputPreprocessed;
break;
case 'G':
- // OpenGL Client
+ // OpenGL client
setOpenGlSpv();
if (argv[0][2] != 0)
ClientInputSemanticsVersion = getAttachedNumber("-G<num> client input semantics");
@@ -736,6 +760,28 @@
if ((Options & EOptionFlattenUniformArrays) != 0 &&
(Options & EOptionReadHlsl) == 0)
Error("uniform array flattening only valid when compiling HLSL source.");
+
+ // rationalize client and target language
+ if (TargetLanguage == glslang::EShTargetNone) {
+ switch (ClientVersion) {
+ case glslang::EShTargetVulkan_1_0:
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_0;
+ break;
+ case glslang::EShTargetVulkan_1_1:
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_3;
+ break;
+ case glslang::EShTargetOpenGL_450:
+ TargetLanguage = glslang::EShTargetSpv;
+ TargetVersion = glslang::EShTargetSpv_1_0;
+ break;
+ default:
+ break;
+ }
+ }
+ if (TargetLanguage != glslang::EShTargetNone && Client == glslang::EShClientNone)
+ Error("To generate SPIR-V, also specify client semantics. See -G and -V.");
}
//
@@ -936,18 +982,11 @@
// Set up the environment, some subsettings take precedence over earlier
// ways of setting things.
if (Options & EOptionSpv) {
- if (Options & EOptionVulkanRules) {
- shader->setEnvInput((Options & EOptionReadHlsl) ? glslang::EShSourceHlsl
- : glslang::EShSourceGlsl,
- compUnit.stage, glslang::EShClientVulkan, ClientInputSemanticsVersion);
- shader->setEnvClient(glslang::EShClientVulkan, VulkanClientVersion);
- } else {
- shader->setEnvInput((Options & EOptionReadHlsl) ? glslang::EShSourceHlsl
- : glslang::EShSourceGlsl,
- compUnit.stage, glslang::EShClientOpenGL, ClientInputSemanticsVersion);
- shader->setEnvClient(glslang::EShClientOpenGL, OpenGLClientVersion);
- }
- shader->setEnvTarget(glslang::EShTargetSpv, TargetVersion);
+ shader->setEnvInput((Options & EOptionReadHlsl) ? glslang::EShSourceHlsl
+ : glslang::EShSourceGlsl,
+ compUnit.stage, Client, ClientInputSemanticsVersion);
+ shader->setEnvClient(Client, ClientVersion);
+ shader->setEnvTarget(TargetLanguage, TargetVersion);
if (targetHlslFunctionality1)
shader->setEnvTargetHlslFunctionality1();
}
@@ -961,8 +1000,7 @@
includer.pushExternalLocalDirectory(dir); });
if (Options & EOptionOutputPreprocessed) {
std::string str;
- if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false,
- messages, &str, includer)) {
+ if (shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, messages, &str, includer)) {
PutsIfNonEmpty(str.c_str());
} else {
CompileFailed = true;
@@ -971,6 +1009,7 @@
StderrIfNonEmpty(shader->getInfoDebugLog());
continue;
}
+
if (! shader->parse(&Resources, defaultVersion, false, messages, includer))
CompileFailed = true;
@@ -1167,13 +1206,15 @@
ProcessConfigFile();
+ if ((Options & EOptionReadHlsl) && !((Options & EOptionOutputPreprocessed) || (Options & EOptionSpv)))
+ Error("ERROR: HLSL requires SPIR-V code generation (or preprocessing only)");
+
//
// Two modes:
// 1) linking all arguments together, single-threaded, new C++ interface
// 2) independent arguments, can be tackled by multiple asynchronous threads, for testing thread safety, using the old handle interface
//
- if (Options & EOptionLinkProgram ||
- Options & EOptionOutputPreprocessed) {
+ if (Options & (EOptionLinkProgram | EOptionOutputPreprocessed)) {
glslang::InitializeProcess();
glslang::InitializeProcess(); // also test reference counting of users
glslang::InitializeProcess(); // also test reference counting of users
@@ -1513,12 +1554,16 @@
" --sep synonym for --source-entrypoint\n"
" --stdin read from stdin instead of from a file;\n"
" requires providing the shader stage using -S\n"
- " --target-env {vulkan1.0 | vulkan1.1 | opengl} \n"
+ " --target-env {vulkan1.0 | vulkan1.1 | opengl | \n"
+ " spirv1.0 | spirv1.1 | spirv1.2 | spirv1.3}\n"
" set execution environment that emitted code\n"
- " will execute in (as opposed to the language\n"
+ " will execute in (versus source language\n"
" semantics selected by --client) defaults:\n"
" * 'vulkan1.0' under '--client vulkan<ver>'\n"
" * 'opengl' under '--client opengl<ver>'\n"
+ " * 'spirv1.0' under --target-env vulkan1.0\n"
+ " * 'spirv1.3' under --target-env vulkan1.1\n"
+ " multiple --targen-env can be specified.\n"
" --variable-name <name>\n"
" --vn <name> creates a C header file that contains a\n"
" uint32_t array named <name>\n"
diff --git a/Test/baseResults/hlsl.pp.expand.frag.err b/Test/baseResults/hlsl.pp.expand.frag.err
index 1b5681f..e69de29 100644
--- a/Test/baseResults/hlsl.pp.expand.frag.err
+++ b/Test/baseResults/hlsl.pp.expand.frag.err
@@ -1,3 +0,0 @@
-ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan.
-ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan.
-
diff --git a/Test/baseResults/spv.perprimitiveNV.frag.out b/Test/baseResults/spv.perprimitiveNV.frag.out
new file mode 100644
index 0000000..eaff400
--- /dev/null
+++ b/Test/baseResults/spv.perprimitiveNV.frag.out
@@ -0,0 +1,54 @@
+spv.perprimitiveNV.frag
+// Module Version 10000
+// Generated by (magic number): 80007
+// Id's are bound by 23
+
+ Capability Shader
+ Capability MeshShadingNV
+ Extension "SPV_NV_mesh_shader"
+ 1: ExtInstImport "GLSL.std.450"
+ MemoryModel Logical GLSL450
+ EntryPoint Fragment 4 "main" 8 11 19
+ ExecutionMode 4 OriginUpperLeft
+ Source GLSL 460
+ SourceExtension "GL_NV_mesh_shader"
+ Name 4 "main"
+ Name 8 "g"
+ Name 9 "B"
+ MemberName 9(B) 0 "f"
+ Name 11 ""
+ Name 17 "C"
+ MemberName 17(C) 0 "h"
+ Name 19 ""
+ Decorate 8(g) Location 8
+ MemberDecorate 9(B) 0 PerPrimitiveNV
+ Decorate 9(B) Block
+ Decorate 11 Location 0
+ MemberDecorate 17(C) 0 Flat
+ MemberDecorate 17(C) 0 Centroid
+ Decorate 17(C) Block
+ Decorate 19 Location 4
+ 2: TypeVoid
+ 3: TypeFunction 2
+ 6: TypeFloat 32
+ 7: TypePointer Output 6(float)
+ 8(g): 7(ptr) Variable Output
+ 9(B): TypeStruct 6(float)
+ 10: TypePointer Input 9(B)
+ 11: 10(ptr) Variable Input
+ 12: TypeInt 32 1
+ 13: 12(int) Constant 0
+ 14: TypePointer Input 6(float)
+ 17(C): TypeStruct 6(float)
+ 18: TypePointer Input 17(C)
+ 19: 18(ptr) Variable Input
+ 4(main): 2 Function None 3
+ 5: Label
+ 15: 14(ptr) AccessChain 11 13
+ 16: 6(float) Load 15
+ 20: 14(ptr) AccessChain 19 13
+ 21: 6(float) Load 20
+ 22: 6(float) FAdd 16 21
+ Store 8(g) 22
+ Return
+ FunctionEnd
diff --git a/Test/runtests b/Test/runtests
index d36f3a8..8cc8b7a 100755
--- a/Test/runtests
+++ b/Test/runtests
@@ -166,13 +166,14 @@
# Test --client and --target-env
#
echo "Testing --client and --target-env"
-$EXE --client vulkan100 spv.targetVulkan.vert || HASERROR=1
-$EXE --client opengl100 spv.targetOpenGL.vert || HASERROR=1
-$EXE --target-env vulkan1.0 spv.targetVulkan.vert || HASERROR=1
-$EXE --target-env vulkan1.1 spv.targetVulkan.vert || HASERROR=1
-$EXE --target-env opengl spv.targetOpenGL.vert || HASERROR=1
-$EXE -V100 spv.targetVulkan.vert || HASERROR=1
-$EXE -G100 spv.targetOpenGL.vert || HASERROR=1
+$EXE --client vulkan100 spv.targetVulkan.vert || HASERROR=1
+$EXE --client opengl100 spv.targetOpenGL.vert || HASERROR=1
+$EXE --target-env vulkan1.0 spv.targetVulkan.vert || HASERROR=1
+$EXE --target-env vulkan1.1 spv.targetVulkan.vert || HASERROR=1
+$EXE --target-env opengl spv.targetOpenGL.vert || HASERROR=1
+$EXE -V100 spv.targetVulkan.vert || HASERROR=1
+$EXE -G100 spv.targetOpenGL.vert || HASERROR=1
+$EXE --target-env spirv1.2 -V spv.targetVulkan.vert || HASERROR=1
#
# Testing GLSL entry point rename
@@ -208,6 +209,7 @@
#
# Testing hlsl_functionality1
#
+echo "Testing hlsl_functionality1"
$EXE -H -e main -D -Od -fhlsl_functionality1 hlsl.structbuffer.incdec.frag > \
$TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out
diff -b $BASEDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out $TARGETDIR/hlsl.structbuffer.incdec.frag.hlslfun1.out || HASERROR=1
@@ -218,6 +220,7 @@
#
# Testing HLSL-specific PP feature expansion
#
+echo "Testing HLSL-specific PP feature expansion"
$EXE -D -E hlsl.pp.expand.frag > $TARGETDIR/hlsl.pp.expand.frag.out 2> $TARGETDIR/hlsl.pp.expand.frag.err
diff -b $BASEDIR/hlsl.pp.expand.frag.out $TARGETDIR/hlsl.pp.expand.frag.out || HASERROR=1
diff -b $BASEDIR/hlsl.pp.expand.frag.err $TARGETDIR/hlsl.pp.expand.frag.err || HASERROR=1
diff --git a/Test/spv.perprimitiveNV.frag b/Test/spv.perprimitiveNV.frag
new file mode 100644
index 0000000..56e00f5
--- /dev/null
+++ b/Test/spv.perprimitiveNV.frag
@@ -0,0 +1,21 @@
+#version 460
+
+#extension GL_NV_mesh_shader: require
+
+layout(location=0)
+in B {
+ perprimitiveNV float f;
+};
+
+layout(location=4)
+in C {
+ flat centroid float h;
+};
+
+layout(location=8)
+out float g;
+
+void main()
+{
+ g = f + h;
+}
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 190f3fc..3063d37 100755
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -4518,6 +4518,8 @@
break;
#ifdef NV_EXTENSIONS
case EShLangTaskNV:
+ requireExtensions(getCurrentLoc(), 1, &E_GL_NV_mesh_shader, "task shaders");
+ break;
case EShLangMeshNV:
requireExtensions(getCurrentLoc(), 1, &E_GL_NV_mesh_shader, "mesh shaders");
break;
diff --git a/glslang/MachineIndependent/Versions.cpp b/glslang/MachineIndependent/Versions.cpp
index 9ca20a5..b26bc3e 100644
--- a/glslang/MachineIndependent/Versions.cpp
+++ b/glslang/MachineIndependent/Versions.cpp
@@ -842,9 +842,12 @@
{
#ifdef NV_EXTENSIONS
// GL_NV_mesh_shader extension is only allowed in task/mesh shaders
- if (strcmp(extension, "GL_NV_mesh_shader") == 0)
- requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask),
+ if (strcmp(extension, "GL_NV_mesh_shader") == 0) {
+ requireStage(loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask | EShLangFragmentMask),
"#extension GL_NV_mesh_shader");
+ profileRequires(loc, ECoreProfile, 450, 0, "#extension GL_NV_mesh_shader");
+ profileRequires(loc, EEsProfile, 320, 0, "#extension GL_NV_mesh_shader");
+ }
#endif
}
diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y
index cd4256d..f6e33c6 100644
--- a/glslang/MachineIndependent/glslang.y
+++ b/glslang/MachineIndependent/glslang.y
@@ -1157,30 +1157,30 @@
}
| PERPRIMITIVENV {
#ifdef NV_EXTENSIONS
+ // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck($1.loc, "perprimitiveNV");
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
- parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perprimitiveNV");
- parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perprimitiveNV");
+ // Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
+ if (parseContext.language == EShLangFragment)
+ parseContext.requireExtensions($1.loc, 1, &E_GL_NV_mesh_shader, "perprimitiveNV");
$$.init($1.loc);
$$.qualifier.perPrimitiveNV = true;
#endif
}
| PERVIEWNV {
#ifdef NV_EXTENSIONS
+ // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck($1.loc, "perviewNV");
parseContext.requireStage($1.loc, EShLangMeshNV, "perviewNV");
- parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perviewNV");
- parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perviewNV");
$$.init($1.loc);
$$.qualifier.perViewNV = true;
#endif
}
| PERTASKNV {
#ifdef NV_EXTENSIONS
+ // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck($1.loc, "taskNV");
parseContext.requireStage($1.loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
- parseContext.profileRequires($1.loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "taskNV");
- parseContext.profileRequires($1.loc, EEsProfile, 320, E_GL_NV_mesh_shader, "taskNV");
$$.init($1.loc);
$$.qualifier.perTaskNV = true;
#endif
diff --git a/glslang/MachineIndependent/glslang_tab.cpp b/glslang/MachineIndependent/glslang_tab.cpp
index 9b9df51..4b70ee3 100644
--- a/glslang/MachineIndependent/glslang_tab.cpp
+++ b/glslang/MachineIndependent/glslang_tab.cpp
@@ -948,7 +948,7 @@
820, 825, 834, 834, 845, 849, 856, 863, 866, 873,
881, 901, 924, 939, 964, 975, 985, 995, 1005, 1014,
1017, 1021, 1025, 1030, 1038, 1043, 1048, 1053, 1058, 1067,
- 1078, 1105, 1114, 1121, 1128, 1139, 1148, 1158, 1168, 1178,
+ 1078, 1105, 1114, 1121, 1128, 1139, 1148, 1158, 1170, 1179,
1191, 1197, 1200, 1207, 1211, 1215, 1223, 1232, 1235, 1246,
1249, 1252, 1256, 1260, 1264, 1268, 1274, 1278, 1290, 1304,
1309, 1315, 1321, 1328, 1334, 1339, 1344, 1349, 1359, 1369,
@@ -5515,40 +5515,40 @@
#line 1158 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{
#ifdef NV_EXTENSIONS
+ // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck((yyvsp[0].lex).loc, "perprimitiveNV");
parseContext.requireStage((yyvsp[0].lex).loc, (EShLanguageMask)(EShLangFragmentMask | EShLangMeshNVMask), "perprimitiveNV");
- parseContext.profileRequires((yyvsp[0].lex).loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perprimitiveNV");
- parseContext.profileRequires((yyvsp[0].lex).loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perprimitiveNV");
+ // Fragment shader stage doesn't check for extension. So we explicitly add below extension check.
+ if (parseContext.language == EShLangFragment)
+ parseContext.requireExtensions((yyvsp[0].lex).loc, 1, &E_GL_NV_mesh_shader, "perprimitiveNV");
(yyval.interm.type).init((yyvsp[0].lex).loc);
(yyval.interm.type).qualifier.perPrimitiveNV = true;
#endif
}
-#line 5527 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
+#line 5529 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break;
case 138:
-#line 1168 "MachineIndependent/glslang.y" /* yacc.c:1646 */
+#line 1170 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{
#ifdef NV_EXTENSIONS
+ // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck((yyvsp[0].lex).loc, "perviewNV");
parseContext.requireStage((yyvsp[0].lex).loc, EShLangMeshNV, "perviewNV");
- parseContext.profileRequires((yyvsp[0].lex).loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "perviewNV");
- parseContext.profileRequires((yyvsp[0].lex).loc, EEsProfile, 320, E_GL_NV_mesh_shader, "perviewNV");
(yyval.interm.type).init((yyvsp[0].lex).loc);
(yyval.interm.type).qualifier.perViewNV = true;
#endif
}
-#line 5542 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
+#line 5543 "MachineIndependent/glslang_tab.cpp" /* yacc.c:1646 */
break;
case 139:
-#line 1178 "MachineIndependent/glslang.y" /* yacc.c:1646 */
+#line 1179 "MachineIndependent/glslang.y" /* yacc.c:1646 */
{
#ifdef NV_EXTENSIONS
+ // No need for profile version or extension check. Shader stage already checks both.
parseContext.globalCheck((yyvsp[0].lex).loc, "taskNV");
parseContext.requireStage((yyvsp[0].lex).loc, (EShLanguageMask)(EShLangTaskNVMask | EShLangMeshNVMask), "taskNV");
- parseContext.profileRequires((yyvsp[0].lex).loc, ECoreProfile, 450, E_GL_NV_mesh_shader, "taskNV");
- parseContext.profileRequires((yyvsp[0].lex).loc, EEsProfile, 320, E_GL_NV_mesh_shader, "taskNV");
(yyval.interm.type).init((yyvsp[0].lex).loc);
(yyval.interm.type).qualifier.perTaskNV = true;
#endif
diff --git a/glslang/Public/ShaderLang.h b/glslang/Public/ShaderLang.h
old mode 100644
new mode 100755
index 74ab352..0708829
--- a/glslang/Public/ShaderLang.h
+++ b/glslang/Public/ShaderLang.h
@@ -154,7 +154,10 @@
typedef enum {
EShTargetSpv_1_0 = (1 << 16),
+ EShTargetSpv_1_1 = (1 << 16) | (1 << 8),
+ EShTargetSpv_1_2 = (1 << 16) | (2 << 8),
EShTargetSpv_1_3 = (1 << 16) | (3 << 8),
+ EShTargetSpv_1_4 = (1 << 16) | (4 << 8),
} EShTargetLanguageVersion;
struct TInputLanguage {
diff --git a/gtests/Spv.FromFile.cpp b/gtests/Spv.FromFile.cpp
index e4b43d4..5f03ac1 100644
--- a/gtests/Spv.FromFile.cpp
+++ b/gtests/Spv.FromFile.cpp
@@ -532,6 +532,7 @@
"spv.meshShaderRedeclBuiltins.mesh",
"spv.meshShaderRedeclPerViewBuiltins.mesh",
"spv.meshTaskShader.task",
+ "spv.perprimitiveNV.frag",
})),
FileNameAsCustomTestSuffix
);
diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp
old mode 100644
new mode 100755
index 1672365..135e1d2
--- a/hlsl/hlslParseHelper.cpp
+++ b/hlsl/hlslParseHelper.cpp
@@ -97,9 +97,6 @@
if (language == EShLangGeometry)
globalOutputDefaults.layoutStream = 0;
-
- if (spvVersion.spv == 0 || spvVersion.vulkan == 0)
- infoSink.info << "ERROR: HLSL currently only supported when requesting SPIR-V for Vulkan.\n";
}
HlslParseContext::~HlslParseContext()