Skip to content

Commit 90c9134

Browse files
committed
Metal: Read gl_ViewIndex for multi-view subpasses
This is necessary to ensure the SpvCapabilityMultiView is included in the SPIR-V, informing downstream transpilers, like Metal, that it should enable multi-view capabilities in the generated Metal shader source.
1 parent 3defc85 commit 90c9134

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

servers/rendering/renderer_rd/shaders/effects/tonemap.glsl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,11 @@ vec3 screen_space_dither(vec2 frag_coord, float bit_alignment_diviser) {
834834
void main() {
835835
#ifdef SUBPASS
836836
// SUBPASS and USE_MULTIVIEW can be combined but in that case we're already reading from the correct layer
837+
#ifdef USE_MULTIVIEW
838+
// In order to ensure the `SpvCapabilityMultiView` is included in the SPIR-V capabilities, gl_ViewIndex must
839+
// be read in the shader. Without this, transpilation to Metal fails to include the multi-view variant.
840+
uint vi = ViewIndex;
841+
#endif
837842
vec4 color = subpassLoad(input_color);
838843
#elif defined(USE_MULTIVIEW)
839844
vec4 color = textureLod(source_color, vec3(uv_interp, ViewIndex), 0.0f);

0 commit comments

Comments
 (0)