mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 15:14:17 +00:00
4d9e7d30b0
When a GdkMemoryFormat is not supported natively and there's postprocessing required, add a way to mark a VulkanImage as such via the new postprocess flags. Also allow texting such iamges only with new_for_upload() and detect when that is the case and then run a postprocessing step that converts that image to a suitable format. This is done with a new "convert" shader/op. This now supports all formats natively, no conversions happen on the CPU anymore (unless the GPU is old).
30 lines
773 B
GLSL
30 lines
773 B
GLSL
#version 450
|
|
|
|
#include "common.frag.glsl"
|
|
#include "clip.frag.glsl"
|
|
#include "rect.frag.glsl"
|
|
|
|
#define GSK_VULKAN_IMAGE_PREMULTIPLY (1 << 0)
|
|
#
|
|
layout(location = 0) in vec2 in_pos;
|
|
layout(location = 1) in Rect in_rect;
|
|
layout(location = 2) in vec2 in_tex_coord;
|
|
layout(location = 3) flat in uint in_tex_id;
|
|
layout(location = 4) in flat uint in_postprocess;
|
|
|
|
layout(location = 0) out vec4 color;
|
|
|
|
void main()
|
|
{
|
|
float alpha = rect_coverage (in_rect, in_pos);
|
|
|
|
/* warning: This breaks with filters other than nearest,
|
|
as linear filtering needs premultiplied alpha */
|
|
vec4 pixel = texture (get_sampler (in_tex_id), in_tex_coord);
|
|
|
|
if ((in_postprocess & GSK_VULKAN_IMAGE_PREMULTIPLY) != 0)
|
|
pixel.rgb *= pixel.a;
|
|
|
|
color = clip_scaled (in_pos, pixel * alpha);
|
|
}
|