Merge pull request #663 from KhronosGroup/fix-660

Use GL_NV_gpu_shader5 as a fallback for AMD_gpu_shader_half_float.
This commit is contained in:
Hans-Kristian Arntzen 2018-08-23 16:22:48 +02:00 committed by GitHub
commit a7697446b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -1,5 +1,11 @@
#version 450
#if defined(GL_AMD_gpu_shader_half_float)
#extension GL_AMD_gpu_shader_half_float : require
#elif defined(GL_NV_gpu_shader5)
#extension GL_NV_gpu_shader5 : require
#else
#error No extension available for FP16.
#endif
layout(location = 3) in f16vec4 v4;

View File

@ -1,5 +1,11 @@
#version 450
#if defined(GL_AMD_gpu_shader_half_float)
#extension GL_AMD_gpu_shader_half_float : require
#elif defined(GL_NV_gpu_shader5)
#extension GL_NV_gpu_shader5 : require
#else
#error No extension available for FP16.
#endif
struct ResType
{

View File

@ -479,7 +479,22 @@ void CompilerGLSL::emit_header()
}
for (auto &ext : forced_extensions)
statement("#extension ", ext, " : require");
{
if (ext == "GL_AMD_gpu_shader_half_float" && !options.vulkan_semantics)
{
// Special case, this extension has a potential fallback to another vendor extension in normal GLSL.
// GL_AMD_gpu_shader_half_float is a superset, so try that first.
statement("#if defined(GL_AMD_gpu_shader_half_float)");
statement("#extension GL_AMD_gpu_shader_half_float : require");
statement("#elif defined(GL_NV_gpu_shader5)");
statement("#extension GL_NV_gpu_shader5 : require");
statement("#else");
statement("#error No extension available for FP16.");
statement("#endif");
}
else
statement("#extension ", ext, " : require");
}
for (auto &header : header_lines)
statement(header);