Fix T95298 ImageEditor: Multi-view images fail to display properly

This was because the shader had wrong output slot order.

This also add a note about why the order is reversed compared to the
texture binding.
This commit is contained in:
Clément Foucault 2022-05-10 12:33:08 +02:00
parent 439f86ac89
commit 061995775f
3 changed files with 11 additions and 20 deletions

View File

@ -267,12 +267,15 @@ void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo
return;
}
/* The composite framebuffer object needs to be created in the window context. */
GPU_framebuffer_ensure_config(&viewport->stereo_comp_fb,
{
GPU_ATTACHMENT_NONE,
GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[0]),
GPU_ATTACHMENT_TEXTURE(viewport->color_render_tx[0]),
});
GPU_framebuffer_ensure_config(
&viewport->stereo_comp_fb,
{
GPU_ATTACHMENT_NONE,
/* We need the sRGB attachment to be first for GL_FRAMEBUFFER_SRGB to be turned on.
* Note that this is the opposite of what the texture binding is. */
GPU_ATTACHMENT_TEXTURE(viewport->color_overlay_tx[0]),
GPU_ATTACHMENT_TEXTURE(viewport->color_render_tx[0]),
});
GPUVertFormat *vert_format = immVertexFormat();
uint pos = GPU_vertformat_attr_add(vert_format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);

View File

@ -5,18 +5,6 @@
#define S3D_INTERLACE_COLUMN 1
#define S3D_INTERLACE_CHECKERBOARD 2
/* Composite stereo textures */
#ifndef USE_GPU_SHADER_CREATE_INFO
uniform sampler2D imageTexture;
uniform sampler2D overlayTexture;
uniform int stereoDisplaySettings;
layout(location = 0) out vec4 imageColor;
layout(location = 1) out vec4 overlayColor;
#endif
#define stereo_display_mode (stereoDisplaySettings & ((1 << 3) - 1))
#define stereo_interlace_mode ((stereoDisplaySettings >> 3) & ((1 << 3) - 1))
#define stereo_interlace_swap bool(stereoDisplaySettings >> 6)

View File

@ -9,8 +9,8 @@
GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_stereo_merge)
.vertex_in(0, Type::VEC2, "pos")
.fragment_out(0, Type::VEC4, "imageColor")
.fragment_out(1, Type::VEC4, "overlayColor")
.fragment_out(0, Type::VEC4, "overlayColor")
.fragment_out(1, Type::VEC4, "imageColor")
.sampler(0, ImageType::FLOAT_2D, "imageTexture")
.sampler(1, ImageType::FLOAT_2D, "overlayTexture")
.push_constant(Type::MAT4, "ModelViewProjectionMatrix")