Merge pull request #256 from KhronosGroup/multiview

Add support for SPV_KHR_multiview.
This commit is contained in:
Hans-Kristian Arntzen 2017-08-15 13:43:07 +02:00 committed by GitHub
commit b0985b6a93
4 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#version 310 es
#extension GL_OVR_multiview2 : require
layout(binding = 0, std140) uniform MVPs
{
mat4 MVP[2];
} _19;
layout(location = 0) in vec4 Position;
void main()
{
gl_Position = _19.MVP[gl_ViewID_OVR] * Position;
}

View File

@ -0,0 +1,15 @@
#version 310 es
#extension GL_EXT_multiview : require
layout(set = 0, binding = 0, std140) uniform MVPs
{
mat4 MVP[2];
} _19;
layout(location = 0) in vec4 Position;
void main()
{
gl_Position = _19.MVP[gl_ViewIndex] * Position;
}

View File

@ -0,0 +1,14 @@
#version 310 es
#extension GL_EXT_multiview : require
layout(std140, binding = 0) uniform MVPs
{
mat4 MVP[2];
};
layout(location = 0) in vec4 Position;
void main()
{
gl_Position = MVP[gl_ViewIndex] * Position;
}

View File

@ -3619,6 +3619,18 @@ string CompilerGLSL::builtin_to_glsl(BuiltIn builtin, StorageClass storage)
SPIRV_CROSS_THROW("gl_SamplePosition not supported before GLSL 400.");
return "gl_SamplePosition";
case BuiltInViewIndex:
if (options.vulkan_semantics)
{
require_extension("GL_EXT_multiview");
return "gl_ViewIndex";
}
else
{
require_extension("GL_OVR_multiview2");
return "gl_ViewID_OVR";
}
default:
return join("gl_BuiltIn_", convert_to_string(builtin));
}