gtk2/gsk/resources/vulkan/clip.vert.glsl
Benjamin Otte 3768c676c6 vulkan: Add clip.vert.glsl
Implement clipping the same way as in the last commit for the
fragment shaders.
2017-01-17 06:17:55 +01: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