7eecf5a46b
This is needed to support `VK_KHR_multiview`, which is in turn needed for Vulkan 1.1 support. Unfortunately, Metal provides no native support for this, and Apple is once again less than forthcoming, so we have to implement it all ourselves. Tessellation and geometry shaders are deliberately unsupported for now. The problem is that the current implementation encodes the `ViewIndex` as part of the `InstanceIndex`, which in the SPIR-V environment at least only exists in the vertex shader. So we need to work out a way to pass the view index along to the later stages. This implementation runs vertex shaders for all views up to the highest bit set in the view mask, even those whose bits are clear. The fragments for the inactive views are then discarded. Avoiding this is difficult: calculating the view indices becomes far more complicated if we can only run for those views which are set in the mask.
15 lines
318 B
GLSL
15 lines
318 B
GLSL
#version 310 es
|
|
#extension GL_EXT_multiview : require
|
|
precision mediump float;
|
|
|
|
layout(location = 0) in vec4 vColor;
|
|
layout(location = 1) in vec2 vTex[4];
|
|
layout(binding = 0) uniform sampler2D uTex;
|
|
layout(location = 0) out vec4 FragColor;
|
|
|
|
void main()
|
|
{
|
|
FragColor = vColor * texture(uTex, vTex[gl_ViewIndex]);
|
|
}
|
|
|