Updated glslang.

This commit is contained in:
Branimir Karadžić 2018-09-15 08:58:21 -07:00
parent 4faf60d903
commit 59178d5cad
19 changed files with 55 additions and 28 deletions

12
3rdparty/glslang/SPIRV/GlslangToSpv.cpp vendored Normal file → Executable file
View File

@ -2729,10 +2729,6 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType = builder.makeFloatType(64);
break;
case glslang::EbtFloat16:
#if AMD_EXTENSIONS
if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
#endif
spvType = builder.makeFloatType(16);
break;
case glslang::EbtBool:
@ -2750,17 +2746,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType = builder.makeUintType(8);
break;
case glslang::EbtInt16:
#ifdef AMD_EXTENSIONS
if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
#endif
spvType = builder.makeIntType(16);
break;
case glslang::EbtUint16:
#ifdef AMD_EXTENSIONS
if (builder.getSpvVersion() < glslang::EShTargetSpv_1_3)
builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
#endif
spvType = builder.makeUintType(16);
break;
case glslang::EbtInt:

19
3rdparty/glslang/SPIRV/SpvPostProcess.cpp vendored Normal file → Executable file
View File

@ -120,6 +120,25 @@ void Builder::postProcessType(const Instruction& inst, Id typeId)
case OpSConvert:
case OpUConvert:
break;
case OpExtInst:
switch (inst.getImmediateOperand(1)) {
#if AMD_EXTENSIONS
case GLSLstd450Frexp:
case GLSLstd450FrexpStruct:
if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeInt, 16))
addExtension(spv::E_SPV_AMD_gpu_shader_int16);
break;
case GLSLstd450InterpolateAtCentroid:
case GLSLstd450InterpolateAtSample:
case GLSLstd450InterpolateAtOffset:
if (getSpvVersion() < glslang::EShTargetSpv_1_3 && containsType(typeId, OpTypeFloat, 16))
addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
break;
#endif
default:
break;
}
break;
default:
if (basicTypeOp == OpTypeFloat && width == 16)
addCapability(CapabilityFloat16);

View File

@ -26,7 +26,7 @@ Dest BitwiseCast(Src source) {
Dest dest;
static_assert(sizeof(source) == sizeof(dest),
"BitwiseCast: Source and destination must have the same size");
std::memcpy(&dest, &source, sizeof(dest));
std::memcpy(static_cast<void*>(&dest), &source, sizeof(dest));
return dest;
}

View File

@ -14,5 +14,6 @@ struct A
void main()
{
"a string"
}

View File

@ -6,7 +6,6 @@ spv.16bitstorage-int.frag
Capability Shader
Capability StorageUniformBufferBlock16
Capability StorageUniform16
Extension "SPV_AMD_gpu_shader_int16"
Extension "SPV_KHR_16bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450

View File

@ -6,7 +6,6 @@ spv.16bitstorage-uint.frag
Capability Shader
Capability StorageUniformBufferBlock16
Capability StorageUniform16
Extension "SPV_AMD_gpu_shader_int16"
Extension "SPV_KHR_16bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450

View File

@ -6,7 +6,6 @@ spv.16bitstorage.frag
Capability Shader
Capability StorageUniformBufferBlock16
Capability StorageUniform16
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_KHR_16bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450

View File

@ -27,7 +27,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Capability StorageInputOutput16
Capability Float16ImageAMD
Capability ImageGatherBiasLodAMD
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_half_float_fetch"
Extension "SPV_AMD_texture_gather_bias_lod"
Extension "SPV_KHR_16bit_storage"

View File

@ -14,7 +14,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Capability Int16
Capability StorageUniform16
Capability StorageInputOutput16
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
Extension "SPV_KHR_16bit_storage"
1: ExtInstImport "GLSL.std.450"

View File

@ -14,8 +14,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Capability Int16
Capability Int8
Capability StorageUniform16
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
Extension "SPV_KHR_16bit_storage"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450

View File

@ -14,8 +14,6 @@ error: Capability Float16 is not allowed by Vulkan 1.0 specification (or require
Capability Groups
Capability Int16
Capability StorageUniformBufferBlock16
Extension "SPV_AMD_gpu_shader_half_float"
Extension "SPV_AMD_gpu_shader_int16"
Extension "SPV_AMD_shader_ballot"
Extension "SPV_KHR_16bit_storage"
1: ExtInstImport "GLSL.std.450"

1
3rdparty/glslang/Test/hlsl.pp.expand.frag vendored Normal file → Executable file
View File

@ -14,4 +14,5 @@ struct A
void main()
{
"a string"
}

View File

@ -1,3 +1,3 @@
// This header is generated by the make-revision script.
#define GLSLANG_PATCH_LEVEL 2880
#define GLSLANG_PATCH_LEVEL 2888

View File

@ -982,7 +982,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"\n");
}
#ifdef NV_EXTENSIONS
if (profile != EEsProfile && version >= 440) {
commonBuiltins.append(
"uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
@ -1032,7 +1031,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"void atomicStore(coherent volatile out int64_t, int64_t, int, int, int);"
"\n");
}
#endif
if ((profile == EEsProfile && version >= 310) ||
(profile != EEsProfile && version >= 450)) {

View File

@ -1858,11 +1858,15 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
if (argp->size() > 3) {
requireExtensions(loc, 1, &E_GL_KHR_memory_scope_semantics, fnCandidate.getName().c_str());
memorySemanticsCheck(loc, fnCandidate, callNode);
}
} else if (arg0->getType().getBasicType() == EbtInt64 || arg0->getType().getBasicType() == EbtUint64) {
#ifdef NV_EXTENSIONS
else if (arg0->getType().getBasicType() == EbtInt64 || arg0->getType().getBasicType() == EbtUint64)
requireExtensions(loc, 1, &E_GL_NV_shader_atomic_int64, fnCandidate.getName().c_str());
const char* const extensions[2] = { E_GL_NV_shader_atomic_int64,
E_GL_EXT_shader_atomic_int64 };
requireExtensions(loc, 2, extensions, fnCandidate.getName().c_str());
#else
requireExtensions(loc, 1, &E_GL_EXT_shader_atomic_int64, fnCandidate.getName().c_str());
#endif
}
break;
}

17
3rdparty/glslang/glslang/MachineIndependent/ShaderLang.cpp vendored Normal file → Executable file
View File

@ -67,6 +67,11 @@
#include "iomapper.h"
#include "Initialize.h"
// TODO: this really shouldn't be here, it is only because of the trial addition
// of printing pre-processed tokens, which requires knowing the string literal
// token to print ", but none of that seems appropriate for this file.
#include "preprocessor/PpTokens.h"
namespace { // anonymous namespace for file-local functions and symbols
// Total number of successful initializers of glslang: a refcount
@ -965,6 +970,8 @@ private:
// DoPreprocessing is a valid ProcessingContext template argument,
// which only performs the preprocessing step of compilation.
// It places the result in the "string" argument to its constructor.
//
// This is not an officially supported or fully working path.
struct DoPreprocessing {
explicit DoPreprocessing(std::string* string): outputString(string) {}
bool operator()(TParseContextBase& parseContext, TPpContext& ppContext,
@ -1072,7 +1079,11 @@ struct DoPreprocessing {
outputBuffer += ' ';
}
lastToken = token;
if (token == PpAtomConstString)
outputBuffer += "\"";
outputBuffer += ppToken.name;
if (token == PpAtomConstString)
outputBuffer += "\"";
} while (true);
outputBuffer += '\n';
*outputString = std::move(outputBuffer);
@ -1122,6 +1133,9 @@ struct DoFullParse{
// Return: True if there were no issues found in preprocessing,
// False if during preprocessing any unknown version, pragmas or
// extensions were found.
//
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
// is not an officially supported or fully working path.
bool PreprocessDeferred(
TCompiler* compiler,
const char* const shaderStrings[],
@ -1726,6 +1740,9 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
// Fill in a string with the result of preprocessing ShaderStrings
// Returns true if all extensions, pragmas and version strings were valid.
//
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
// is not an officially supported or fully working path.
bool TShader::preprocess(const TBuiltInResource* builtInResources,
int defaultVersion, EProfile defaultProfile,
bool forceDefaultVersionAndProfile,

View File

@ -196,6 +196,8 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_KHR_shader_subgroup_quad] = EBhDisable;
extensionBehavior[E_GL_KHR_memory_scope_semantics] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_atomic_int64] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_non_constant_global_initializers] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_image_load_formatted] = EBhDisable;
extensionBehavior[E_GL_EXT_post_depth_coverage] = EBhDisable;
@ -381,6 +383,8 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_KHR_shader_subgroup_clustered 1\n"
"#define GL_KHR_shader_subgroup_quad 1\n"
"#define E_GL_EXT_shader_atomic_int64 1\n"
#ifdef AMD_EXTENSIONS
"#define GL_AMD_shader_ballot 1\n"
"#define GL_AMD_shader_trinary_minmax 1\n"

View File

@ -150,6 +150,8 @@ const char* const E_GL_KHR_shader_subgroup_clustered = "GL_KHR_shader_sub
const char* const E_GL_KHR_shader_subgroup_quad = "GL_KHR_shader_subgroup_quad";
const char* const E_GL_KHR_memory_scope_semantics = "GL_KHR_memory_scope_semantics";
const char* const E_GL_EXT_shader_atomic_int64 = "GL_EXT_shader_atomic_int64";
const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";
const char* const E_GL_EXT_shader_image_load_formatted = "GL_EXT_shader_image_load_formatted";

2
3rdparty/glslang/glslang/Public/ShaderLang.h vendored Normal file → Executable file
View File

@ -532,6 +532,8 @@ public:
return parse(builtInResources, defaultVersion, ENoProfile, false, forwardCompatible, messages, includer);
}
// NOTE: Doing just preprocessing to obtain a correct preprocessed shader string
// is not an officially supported or fully working path.
bool preprocess(const TBuiltInResource* builtInResources,
int defaultVersion, EProfile defaultProfile, bool forceDefaultVersionAndProfile,
bool forwardCompatible, EShMessages message, std::string* outputString,