gtk2/gsk/vulkan/resources/clip.vert.glsl
Matthias Clasen 900a4e4d31 gsk: Move shader resources
Move the resources of each renderer to its subdirectory.
We've previously done that for the ngl renderer, but it
is better to be consistent and do it for all the renderers.
2021-04-03 08:24:58 -04:00

37 lines
763 B
GLSL

#include "constants.glsl"
#ifndef _CLIP_
#define _CLIP_
vec4 intersect(vec4 a, vec4 b)
{
a = vec4(a.xy, a.xy + a.zw);
b = vec4(b.xy, b.xy + b.zw);
vec4 result = vec4(max(a.xy, b.xy), min(a.zw, b.zw));
if (any (greaterThanEqual (result.xy, result.zw)))
return vec4(0.0,0.0,0.0,0.0);
return vec4(result.xy, result.zw - result.xy);
}
#ifdef CLIP_ROUNDED_RECT
vec4 clip(vec4 rect)
{
/* rounded corner clipping is done in fragment shader */
return intersect(rect, push.clip_bounds);
}
#elif defined(CLIP_RECT)
vec4 clip(vec4 rect)
{
return intersect(rect, push.clip_bounds);
}
#elif defined(CLIP_NONE)
vec4 clip(vec4 rect)
{
return rect;
}
#else
#error "No clipping define given. Need CLIP_NONE, CLIP_RECT or CLIP_ROUNDED_RECT"
#endif
#endif